MCPcopy
hub / github.com/getsentry/sentry / get_group_progress_states

Function get_group_progress_states

src/sentry/issues/progress.py:45–129  ·  view source on GitHub ↗

XXX(malwilley): This is a temporary function to derive progress from Activity records. It will be replaced by a derived property on the group action log when available.

(
    group_ids: Sequence[int],
)

Source from the content-addressed store, hash-verified

43
44
45def get_group_progress_states(
46 group_ids: Sequence[int],
47) -> dict[int, str]:
48 """
49 XXX(malwilley): This is a temporary function to derive progress from Activity records.
50 It will be replaced by a derived property on the group action log when available.
51 """
52
53 if not group_ids:
54 return {}
55
56 assigned_group_ids = set[int](
57 GroupAssignee.objects.filter(group_id__in=group_ids).values_list("group_id", flat=True)
58 )
59
60 all_progress_activity_types = [
61 t for types in ISSUE_PROGRESS_TO_ACTIVITY_TYPES.values() for t in types
62 ]
63
64 rows = (
65 Activity.objects.filter(
66 group_id__in=group_ids,
67 type__in=set(all_progress_activity_types) | {ActivityType.SET_REGRESSION.value},
68 )
69 .values("group_id")
70 .annotate(
71 latest_regression=Max(
72 "datetime",
73 filter=Q(type=ActivityType.SET_REGRESSION.value),
74 ),
75 latest_diagnosed=Max(
76 "datetime",
77 filter=Q(type__in=ISSUE_PROGRESS_TO_ACTIVITY_TYPES[IssueProgressState.DIAGNOSED]),
78 ),
79 latest_fix_proposed=Max(
80 "datetime",
81 filter=Q(
82 type__in=ISSUE_PROGRESS_TO_ACTIVITY_TYPES[IssueProgressState.FIX_PROPOSED]
83 ),
84 ),
85 latest_fix_applied=Max(
86 "datetime",
87 filter=Q(type__in=ISSUE_PROGRESS_TO_ACTIVITY_TYPES[IssueProgressState.FIX_APPLIED]),
88 ),
89 )
90 )
91
92 annotation_key_by_state = {
93 IssueProgressState.FIX_APPLIED: "latest_fix_applied",
94 IssueProgressState.FIX_PROPOSED: "latest_fix_proposed",
95 IssueProgressState.DIAGNOSED: "latest_diagnosed",
96 }
97
98 result: dict[int, str] = {}
99 groups_with_activities = set()
100
101 for row in rows:
102 group_id = row["group_id"]

Calls 4

addMethod · 0.65
setFunction · 0.50
filterMethod · 0.45
valuesMethod · 0.45