Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add methods to query + insert coverage measurements #425

Merged
merged 4 commits into from
Feb 28, 2024

Conversation

adrian-codecov
Copy link
Contributor

Purpose/Motivation

We're adding a partitioned with the UserMeasurements models. We want to add some functions to add/query for monthly uploads. This PR adds those + tests

Links to relevant tickets

codecov/engineering-team#1174

What does this PR do?

  • adds a query + insert functions using the user measurements model
  • adds tests to those

Notes to Reviewer

Anything to note to the team? Any tips on how to review, or where to start?

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. In 2022 this entity acquired Codecov and as result Sentry is going to need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

@codecov-staging
Copy link

codecov-staging bot commented Feb 28, 2024

Codecov Report

Attention: Patch coverage is 94.11765% with 1 lines in your changes are missing coverage. Please review.

Files Patch % Lines
plan/service.py 50.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@codecov-qa
Copy link

codecov-qa bot commented Feb 28, 2024

Codecov Report

Attention: Patch coverage is 94.11765% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 95.94%. Comparing base (4fe7a73) to head (b720c27).

Files Patch % Lines
plan/service.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #425      +/-   ##
==========================================
- Coverage   95.94%   95.94%   -0.01%     
==========================================
  Files         641      641              
  Lines       16938    16954      +16     
==========================================
+ Hits        16252    16267      +15     
- Misses        686      687       +1     
Flag Coverage Δ
unit 95.94% <94.11%> (-0.01%) ⬇️
unit-latest-uploader 95.94% <94.11%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

codecov-public-qa bot commented Feb 28, 2024

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (4fe7a73) 95.94% compared to head (b720c27) 95.94%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #425      +/-   ##
==========================================
- Coverage   95.94%   95.94%   -0.01%     
==========================================
  Files         641      641              
  Lines       16938    16954      +16     
==========================================
+ Hits        16252    16267      +15     
- Misses        686      687       +1     
Flag Coverage Δ
unit 95.94% <94.11%> (-0.01%) ⬇️
unit-latest-uploader 95.94% <94.11%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
plan/test_plan.py 100.00% <100.00%> (ø)
utils/uploads_used.py 89.65% <100.00%> (+2.98%) ⬆️
plan/service.py 96.09% <50.00%> (-0.74%) ⬇️

Impacted file tree graph

Copy link

codecov bot commented Feb 28, 2024

Codecov Report

Attention: Patch coverage is 94.11765% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 95.80%. Comparing base (4fe7a73) to head (0ef3a7a).

❗ Current head 0ef3a7a differs from pull request most recent head b720c27. Consider uploading reports for the commit b720c27 to get more accurate results

Files Patch % Lines
plan/service.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main    #425     +/-   ##
=======================================
+ Coverage   95.66   95.80   +0.14     
=======================================
  Files        763     762      -1     
  Lines      17524   17469     -55     
=======================================
- Hits       16764   16735     -29     
+ Misses       760     734     -26     
Flag Coverage Δ
unit 96.09% <94.11%> (+0.14%) ⬆️
unit-latest-uploader 96.09% <94.11%> (+0.14%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -80,3 +84,43 @@ def query_uploads_used(plan_service, limit, owner):
)

return queryset[:limit].count()


def query_monthly_coverage_measurements(plan_service: PlanService) -> int:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How will this be used? How come it only does private repo?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is currently not in use but will replace the query_uploads_used fn. It's mimicking the logic there, excluding the uploaded filter (there's 2 types so far, uploaded and carriedforward; this new user_measurements table will only insert uploaded entries, so no need for it anymore) and the ...timedelta(days=60) as that was a stab at performance, which this whole approach will take care of now

queryset = queryset.filter(
Q(created_at__gte=plan_service.trial_end_date)
| Q(created_at__lte=plan_service.trial_start_date)
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to filter out ONGOING rows?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you're ongoing, you're in the users-trial plan, so there's no monthly_limit associated with it, so it automatically takes care of this

@adrian-codecov adrian-codecov merged commit 5b05170 into main Feb 28, 2024
13 of 18 checks passed
@adrian-codecov adrian-codecov deleted the 1174-create-user_upload_queries branch February 28, 2024 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants