@@ -75,8 +75,8 @@ class ProjectContext:
7575 def __init__ (self , project ):
7676 self .project = project
7777
78- # Array of (group_id, group_history, count)
79- self .key_errors = []
78+ self . key_errors_by_id : list [ tuple [ int , int ]] = []
79+ self .key_errors_by_group : list [ tuple [ Group , int ]] = []
8080 # Array of (transaction_name, count_this_week, p95_this_week, count_last_week, p95_last_week)
8181 self .key_transactions = []
8282 # Array of (Group, count)
@@ -94,7 +94,7 @@ def __init__(self, project):
9494 def __repr__ (self ):
9595 return "\n " .join (
9696 [
97- f"{ self .key_errors } , " ,
97+ f"{ self .key_errors_by_group } , " ,
9898 f"Errors: [Accepted { self .accepted_error_count } , Dropped { self .dropped_error_count } ]" ,
9999 f"Transactions: [Accepted { self .accepted_transaction_count } Dropped { self .dropped_transaction_count } ]" ,
100100 f"Replays: [Accepted { self .accepted_replay_count } Dropped { self .dropped_replay_count } ]" ,
@@ -103,7 +103,7 @@ def __repr__(self):
103103
104104 def check_if_project_is_empty (self ):
105105 return (
106- not self .key_errors
106+ not self .key_errors_by_group
107107 and not self .key_transactions
108108 and not self .key_performance_issues
109109 and not self .accepted_error_count
@@ -116,26 +116,21 @@ def check_if_project_is_empty(self):
116116
117117
118118class DailySummaryProjectContext :
119- total_today = 0
120- comparison_period_total = 0
121- comparison_period_avg = 0
122- key_errors : list [tuple [Group , int ]] = []
123- key_performance_issues : list [tuple [Group , int ]] = []
124- escalated_today : list [Group ] = []
125- regressed_today : list [Group ] = []
126- new_in_release : dict [int , list [Group ]] = {}
127-
128119 def __init__ (self , project : Project ):
120+ self .total_today = 0
121+ self .comparison_period_total = 0
122+ self .comparison_period_avg = 0
129123 self .project = project
130- self .key_errors = []
131- self .key_performance_issues = []
132- self .escalated_today = []
133- self .regressed_today = []
134- self .new_in_release = {}
124+ self .key_errors_by_id : list [tuple [int , int ]] = []
125+ self .key_errors_by_group : list [tuple [Group , int ]] = []
126+ self .key_performance_issues : list [tuple [Group , int ]] = []
127+ self .escalated_today : list [Group ] = []
128+ self .regressed_today : list [Group ] = []
129+ self .new_in_release : dict [int , list [Group ]] = {}
135130
136131 def check_if_project_is_empty (self ):
137132 return (
138- not self .key_errors
133+ not self .key_errors_by_group
139134 and not self .key_performance_issues
140135 and not self .total_today
141136 and not self .comparison_period_total
@@ -217,7 +212,7 @@ def project_key_errors(
217212 )
218213 query_result = raw_snql_query (request , referrer = referrer )
219214 key_errors = query_result ["data" ]
220- # Set project_ctx.key_errors to be an array of (group_id, count) for now.
215+ # Set project_ctx.key_errors_by_id to be an array of (group_id, count) for now.
221216 # We will query the group history later on in `fetch_key_error_groups`, batched in a per-organization basis
222217 return key_errors
223218
@@ -346,7 +341,7 @@ def fetch_key_error_groups(ctx: OrganizationReportContext) -> None:
346341 # Organization pass. Depends on project_key_errors.
347342 all_key_error_group_ids = []
348343 for project_ctx in ctx .projects_context_map .values ():
349- all_key_error_group_ids .extend ([group_id for group_id , count in project_ctx .key_errors ])
344+ all_key_error_group_ids .extend ([group_id for group_id , _ in project_ctx .key_errors_by_id ])
350345
351346 if len (all_key_error_group_ids ) == 0 :
352347 return
@@ -358,19 +353,14 @@ def fetch_key_error_groups(ctx: OrganizationReportContext) -> None:
358353 for project_ctx in ctx .projects_context_map .values ():
359354 # note Snuba might have groups that have since been deleted
360355 # we should just ignore those
361- project_ctx .key_errors = list (
362- filter (
363- lambda x : x [0 ] is not None ,
364- [
365- (
366- group_id_to_group .get (group_id ),
367- None ,
368- count ,
369- )
370- for group_id , count in project_ctx .key_errors
371- ],
356+ project_ctx .key_errors_by_group = [
357+ (group , count )
358+ for group , count in (
359+ (group_id_to_group .get (group_id ), count )
360+ for group_id , count in project_ctx .key_errors_by_id
372361 )
373- )
362+ if group is not None
363+ ]
374364
375365
376366def fetch_key_performance_issue_groups (ctx : OrganizationReportContext ):
0 commit comments