-
Notifications
You must be signed in to change notification settings - Fork 11
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
fix: N+1 query for plans / tiers #1060
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## main #1060 +/- ##
========================================
Coverage 97.52% 97.52%
========================================
Files 462 463 +1
Lines 37902 38037 +135
========================================
+ Hits 36963 37095 +132
- Misses 939 942 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Codecov ReportAll modified and coverable lines are covered by tests ✅ ✅ All tests successful. No failed tests found. 📢 Thoughts on this report? Let us know! |
✅ All tests successful. No failed tests were found. 📣 Thoughts on this report? Let Codecov know! | Powered by Codecov |
PlanName.TEAM_MONTHLY.value, | ||
PlanName.TEAM_YEARLY.value, | ||
}: | ||
if owner_plan.tier_name == TierName.TEAM.value: |
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.
this is a reference that was missed prior, it should be using the tier derived from the plan rather than a hard coded set of plans
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.
NICE
PlanName.TEAM_MONTHLY.value, | ||
PlanName.TEAM_YEARLY.value, | ||
}: | ||
if owner_plan.tier_name == TierName.TEAM.value: |
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.
NICE
This PR aims to fix an N+1 query that was introduced when swapping to the plan model as the source of truth from the consts in shared for the same.
Previously we were calling the plan query n number of times depending on how many values get returned in line 179 here:
worker/services/notification/__init__.py
Lines 179 to 185 in 2508bbc
This cascaded down to
worker/services/notification/__init__.py
Lines 93 to 94 in 2508bbc
worker/services/notification/__init__.py
Lines 73 to 74 in 2508bbc
My fix is to persist the plan on the NotificationService object so if it exists we skip calling the query and just use that reference instead. I tested this against some of the existing UTs with prints to confirm the plan was persisted as I expected.
Closes https://github.com/codecov/internal-issues/issues/1195
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.