-
Notifications
You must be signed in to change notification settings - Fork 28
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
Cache upload usage #315
Conversation
Codecov ReportAttention:
📢 Thoughts on this report? Let us know! |
Codecov ReportAttention:
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Codecov Report
@@ 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
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Codecov ReportAttention:
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this 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
|
||
|
||
def get_uploads_used(redis, plan_service, limit, owner): | ||
cache_key = f"monthly_upload_usage_{owner.ownerid}" |
There was a problem hiding this comment.
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"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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.