Skip to content

feat(aci): Only update open periods if the initial one exists #90079

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

snigdhas
Copy link
Member

@snigdhas snigdhas commented Apr 22, 2025

Step 1 to get us ready for the open period backfill

In order to cleanly backfill open periods, we need to change the existing open period logic to only update an open period for a group if the group has the initial open period (from group creation). If it doesn't, then do nothing. If it does, handle the open periods as usual.

This PR makes that change, using has_initial_open_period to check for an open period that matches the group.first_seen time.

I've also relocated all the open period methods to groupopenperiod.py instead of group.py.

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Apr 22, 2025
Comment on lines +1718 to +1720
if features.has(
"organizations:issue-open-periods", group.project.organization
) and has_initial_open_period(group):
Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry for the larger diff - calling out the logic changes

@@ -1063,185 +1061,3 @@ def pre_save_group_default_substatus(instance, sender, *args, **kwargs):
"No substatus allowed for group",
extra={"status": instance.status, "substatus": instance.substatus},
)

Copy link
Member Author

Choose a reason for hiding this comment

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

all of this is moved to groupopenperiod.py

Comment on lines +215 to +218
# Until we've backfilled the GroupOpenPeriod table, we don't want to update open periods for
# groups that weren't initially created with one.
if not has_initial_open_period(group):
return
Copy link
Member Author

Choose a reason for hiding this comment

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

the other bit of new logic, along with the function def at the end of the file

Comment on lines +261 to +262
def has_initial_open_period(group: Group) -> bool:
return GroupOpenPeriod.objects.filter(group=group, date_started__lte=group.first_seen).exists()
Copy link
Member Author

Choose a reason for hiding this comment

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

last new piece

Copy link

codecov bot commented Apr 22, 2025

Codecov Report

Attention: Patch coverage is 78.72340% with 20 lines in your changes missing coverage. Please review.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/sentry/models/groupopenperiod.py 74.68% 20 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           master   #90079    +/-   ##
========================================
  Coverage   87.64%   87.65%            
========================================
  Files       10250    10260    +10     
  Lines      577029   577652   +623     
  Branches    22719    22719            
========================================
+ Hits       505725   506321   +596     
- Misses      70861    70888    +27     
  Partials      443      443            

@snigdhas snigdhas marked this pull request as ready for review April 22, 2025 18:03
@snigdhas snigdhas requested review from a team as code owners April 22, 2025 18:03
@snigdhas snigdhas requested a review from a team April 22, 2025 18:03
Copy link
Member

@wedamija wedamija left a comment

Choose a reason for hiding this comment

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

These changes look good to me, but I think we need a test to validate

@snigdhas
Copy link
Member Author

whoops, added tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants