-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ref(grouping): Add
create_or_update_grouphash_metadata
helper (#79512)
This moves the grouphash-metadata-related code from `get_or_create_grouphashes` into a new helper function, `create_or_update_grouphash_metadata`, in its own module, in anticipation of a bunch more related code being added shortly.
- Loading branch information
1 parent
a345553
commit 57b3184
Showing
2 changed files
with
26 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from __future__ import annotations | ||
|
||
from sentry.models.grouphash import GroupHash | ||
from sentry.models.grouphashmetadata import GroupHashMetadata | ||
|
||
|
||
def create_or_update_grouphash_metadata( | ||
grouphash: GroupHash, | ||
created: bool, | ||
grouping_config: str, | ||
) -> None: | ||
# TODO: Do we want to expand this to backfill metadata for existing grouphashes? If we do, | ||
# we'll have to override the metadata creation date for them. | ||
|
||
if created: | ||
GroupHashMetadata.objects.create( | ||
grouphash=grouphash, | ||
latest_grouping_config=grouping_config, | ||
) | ||
elif grouphash.metadata and grouphash.metadata.latest_grouping_config != grouping_config: | ||
# Keep track of the most recent config which computed this hash, so that once a | ||
# config is deprecated, we can clear out the GroupHash records which are no longer | ||
# being produced | ||
grouphash.metadata.update(latest_grouping_config=grouping_config) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters