From 3351f4b4008590e2d0e1890658cd335bd80748c7 Mon Sep 17 00:00:00 2001 From: Snigdha Sharma Date: Tue, 5 Dec 2023 16:45:54 -0800 Subject: [PATCH 1/3] Set Activity and GroupHistory for status change --- src/sentry/tasks/post_process.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/sentry/tasks/post_process.py b/src/sentry/tasks/post_process.py index abdf041511733f..4e00e15a0d6b39 100644 --- a/src/sentry/tasks/post_process.py +++ b/src/sentry/tasks/post_process.py @@ -1355,7 +1355,10 @@ def detect_new_escalation(job: PostProcessJob): If we detect that the group has escalated, set has_escalated to True in the job. """ + from sentry.models.activity import Activity + from sentry.models.grouphistory import GroupHistoryStatus, record_group_history from sentry.models.groupinbox import GroupInboxReason, add_group_to_inbox + from sentry.types.activity import ActivityType group = job["event"].group if not group or not features.has( @@ -1372,10 +1375,17 @@ def detect_new_escalation(job: PostProcessJob): with lock.acquire(): project_escalation_rate = get_project_counts(group.project) group_hourly_event_rate = group.times_seen_with_pending / group_age_hours + # TODO(snigdha): reuse manage_issue_states when we allow escalating from other statuses if group_hourly_event_rate > project_escalation_rate: job["has_escalated"] = True group.update(substatus=GroupSubStatus.ESCALATING) add_group_to_inbox(group, GroupInboxReason.ESCALATING) + record_group_history(group, GroupHistoryStatus.ESCALATING) + Activity.objects.create_group_activity( + group=group, + type=ActivityType.SET_ESCALATING, + data={"event_id": job["event"].event_id}, + ) except UnableToAcquireLock: return From 6079fdc13adf4010ba7def22d0864ad11e8145f4 Mon Sep 17 00:00:00 2001 From: "getsantry[bot]" <66042841+getsantry[bot]@users.noreply.github.com> Date: Wed, 6 Dec 2023 18:55:08 +0000 Subject: [PATCH 2/3] :hammer_and_wrench: apply pre-commit fixes --- src/sentry/tasks/post_process.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sentry/tasks/post_process.py b/src/sentry/tasks/post_process.py index be3f9a81c7587f..e776694f47d8af 100644 --- a/src/sentry/tasks/post_process.py +++ b/src/sentry/tasks/post_process.py @@ -1355,9 +1355,9 @@ def detect_new_escalation(job: PostProcessJob): If we detect that the group has escalated, set has_escalated to True in the job. """ + from sentry.issues.issue_velocity import get_latest_threshold from sentry.models.activity import Activity from sentry.models.grouphistory import GroupHistoryStatus, record_group_history - from sentry.issues.issue_velocity import get_latest_threshold from sentry.models.groupinbox import GroupInboxReason, add_group_to_inbox from sentry.types.activity import ActivityType @@ -1385,7 +1385,7 @@ def detect_new_escalation(job: PostProcessJob): if project_escalation_rate > 0 and group_hourly_event_rate > project_escalation_rate: job["has_escalated"] = True group.update(substatus=GroupSubStatus.ESCALATING) - + # TODO(snigdha): reuse manage_issue_states when we allow escalating from other statuses add_group_to_inbox(group, GroupInboxReason.ESCALATING)\ record_group_history(group, GroupHistoryStatus.ESCALATING) From 46a67b6590ed4175f75da0579d8716d7039368d8 Mon Sep 17 00:00:00 2001 From: Snigdha Sharma Date: Wed, 6 Dec 2023 10:55:48 -0800 Subject: [PATCH 3/3] Update post_process.py --- src/sentry/tasks/post_process.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sentry/tasks/post_process.py b/src/sentry/tasks/post_process.py index e776694f47d8af..99390b36efad59 100644 --- a/src/sentry/tasks/post_process.py +++ b/src/sentry/tasks/post_process.py @@ -1387,7 +1387,7 @@ def detect_new_escalation(job: PostProcessJob): group.update(substatus=GroupSubStatus.ESCALATING) # TODO(snigdha): reuse manage_issue_states when we allow escalating from other statuses - add_group_to_inbox(group, GroupInboxReason.ESCALATING)\ + add_group_to_inbox(group, GroupInboxReason.ESCALATING) record_group_history(group, GroupHistoryStatus.ESCALATING) Activity.objects.create_group_activity( group=group,