-
Notifications
You must be signed in to change notification settings - Fork 29
Add filter condition to update less often #1080
Conversation
| def test_push_updates_commit_on_default_branch(self): | ||
| commit1 = CommitFactory(merged=False, repository=self.repo) | ||
| commit2 = CommitFactory(merged=False, repository=self.repo) | ||
| commit1 = CommitFactory( |
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.
Had to change branch name for these commits to non-default branch names for the test to make sense - I believe it originally wasn't working as intended
webhook_handlers/views/github.py
Outdated
| commits=[commit.get("id") for commit in commits], | ||
| ), | ||
| ) | ||
| else: |
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.
Had to do it this way because after a django update, if your original query is no longer satisfied, which was the case when we updated the branch to pushed_to_branch_name, then your queryset no longer uses records. This is the same logic because both if's do an update, only difference is that the first if also does the merged=True
Codecov ReportAttention: Patch coverage is
Changes have been made to critical files, which contain lines commonly executed in production. Learn more ✅ All tests successful. No failed tests found.
Additional details and impacted files@@ Coverage Diff @@
## main #1080 +/- ##
==========================================
- Coverage 96.02% 96.02% -0.01%
==========================================
Files 828 828
Lines 19486 19485 -1
==========================================
- Hits 18712 18710 -2
- Misses 774 775 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Codecov ReportAttention: Patch coverage is ✅ 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 |
webhook_handlers/views/github.py
Outdated
| log.info( | ||
| f"Branch name updated for commits to {branch_name}", | ||
| f"Branch name updated for commits to {pushed_to_branch_name}", | ||
| extra=dict( |
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 will probably also need to be in the if statement now. We're not updating the branch if it's not the default branch.
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.
Pushed and consolidated into 1 log
| if branch_name == repo.branch: | ||
| commits_queryset.update(merged=True) | ||
|
|
||
| if pushed_to_branch_name == repo.branch: |
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.
For more optimization, we can probably also call this before querying.
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.
donee
Purpose/Motivation
We're getting hammered by lock contention and trying to minimize calls that lock the DB. This was one of them, so made adjustments for it.
Links to relevant tickets
codecov/engineering-team#3173
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.