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

Cache upload usage #315

Merged
merged 6 commits into from
Feb 5, 2024
Merged

Cache upload usage #315

merged 6 commits into from
Feb 5, 2024

Conversation

trent-codecov
Copy link
Contributor

Purpose/Motivation

The select for upload usage is a bit slow. This will reduce usage of that query.

Refactors upload usage query to utils.

Links to relevant tickets

What does this PR do?

Include a brief description of the changes in this PR. Bullet points are your friend.

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 Dec 20, 2023

Codecov Report

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

Files Patch % Lines
utils/uploads_used.py 90.00% 4 Missing ⚠️

📢 Thoughts on this report? Let us know!

@codecov-qa
Copy link

codecov-qa bot commented Dec 20, 2023

Codecov Report

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

Comparison is base (5c8102a) 96.09% compared to head (a9021a3) 96.07%.

Files Patch % Lines
utils/uploads_used.py 90.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #315      +/-   ##
==========================================
- Coverage   96.09%   96.07%   -0.02%     
==========================================
  Files         633      634       +1     
  Lines       16489    16530      +41     
==========================================
+ Hits        15845    15882      +37     
- Misses        644      648       +4     
Flag Coverage Δ
unit 96.07% <93.22%> (-0.02%) ⬇️
unit-latest-uploader 96.07% <93.22%> (-0.02%) ⬇️

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 Dec 20, 2023

Codecov Report

Merging #315 (a9021a3) into main (5c8102a) will decrease coverage by 0.02%.
The diff coverage is 93.22%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #315      +/-   ##
==========================================
- Coverage   96.09%   96.07%   -0.02%     
==========================================
  Files         633      634       +1     
  Lines       16489    16530      +41     
==========================================
+ Hits        15845    15882      +37     
- Misses        644      648       +4     
Flag Coverage Δ
unit 96.07% <93.22%> (-0.02%) ⬇️
unit-latest-uploader 96.07% <93.22%> (-0.02%) ⬇️

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

Files Coverage Δ
...s/owner/interactors/get_uploads_number_per_user.py 100.00% <100.00%> (ø)
upload/helpers.py 94.33% <100.00%> (+0.08%) ⬆️
upload/throttles.py 90.90% <100.00%> (ø)
utils/uploads_used.py 90.00% <90.00%> (ø)

Impacted file tree graph

Copy link

codecov bot commented Dec 20, 2023

Codecov Report

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

Comparison is base (90bec21) 95.62% compared to head (4cb9ec3) 95.67%.

❗ Current head 4cb9ec3 differs from pull request most recent head 08815c4. Consider uploading reports for the commit 08815c4 to get more accurate results

Files Patch % Lines
utils/uploads_used.py 82.50% 7 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main    #315     +/-   ##
=======================================
+ Coverage   95.62   95.67   +0.05     
=======================================
  Files        728     729      +1     
  Lines      16386   16628    +242     
=======================================
+ Hits       15668   15908    +240     
- Misses       718     720      +2     
Flag Coverage Δ
unit 95.96% <88.13%> (-0.04%) ⬇️
unit-latest-uploader 95.96% <88.13%> (-0.04%) ⬇️

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
Contributor

@joseph-sentry joseph-sentry left a comment

Choose a reason for hiding this comment

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

lgtm, just one quick comment

utils/uploads_used.py Show resolved Hide resolved


def get_uploads_used(redis, plan_service, limit, owner):
cache_key = f"monthly_upload_usage_{owner.ownerid}"
Copy link
Contributor

Choose a reason for hiding this comment

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

[nit] make the cache key some global lambda function in the file level. Reduces the number of places you need to update in case the key needs to change.

CACHE_KEY = lambda ownerid: f"monthly_upload_usage_{ownerid}"


assert CACHE_KEY(10) == "monthly_upload_usage_10"

@trent-codecov trent-codecov merged commit 7d7beed into main Feb 5, 2024
14 of 20 checks passed
@trent-codecov trent-codecov deleted the trent/cache-upload-usage branch February 5, 2024 15:02
Copy link

@barnett-yuxiang barnett-yuxiang left a comment

Choose a reason for hiding this comment

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

LGTM

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.

None yet

4 participants