@@ -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
@@ -127,15 +127,16 @@ class DailySummaryProjectContext:
127127
128128 def __init__ (self , project : Project ):
129129 self .project = project
130- self .key_errors = []
130+ self .key_errors_by_id : list [tuple [int , int ]] = []
131+ self .key_errors_by_group : list [tuple [Group , int ]] = []
131132 self .key_performance_issues = []
132133 self .escalated_today = []
133134 self .regressed_today = []
134135 self .new_in_release = {}
135136
136137 def check_if_project_is_empty (self ):
137138 return (
138- not self .key_errors
139+ not self .key_errors_by_group
139140 and not self .key_performance_issues
140141 and not self .total_today
141142 and not self .comparison_period_total
@@ -217,7 +218,7 @@ def project_key_errors(
217218 )
218219 query_result = raw_snql_query (request , referrer = referrer )
219220 key_errors = query_result ["data" ]
220- # Set project_ctx.key_errors to be an array of (group_id, count) for now.
221+ # Set project_ctx.key_errors_by_id to be an array of (group_id, count) for now.
221222 # We will query the group history later on in `fetch_key_error_groups`, batched in a per-organization basis
222223 return key_errors
223224
@@ -346,7 +347,7 @@ def fetch_key_error_groups(ctx: OrganizationReportContext) -> None:
346347 # Organization pass. Depends on project_key_errors.
347348 all_key_error_group_ids = []
348349 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 ])
350+ all_key_error_group_ids .extend ([group_id for group_id , _ in project_ctx .key_errors_by_id ])
350351
351352 if len (all_key_error_group_ids ) == 0 :
352353 return
@@ -358,19 +359,14 @@ def fetch_key_error_groups(ctx: OrganizationReportContext) -> None:
358359 for project_ctx in ctx .projects_context_map .values ():
359360 # note Snuba might have groups that have since been deleted
360361 # 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- ],
362+ project_ctx .key_errors_by_group = [
363+ (group , count )
364+ for group , count in (
365+ (group_id_to_group .get (group_id ), count )
366+ for group_id , count in project_ctx .key_errors_by_id
372367 )
373- )
368+ if group is not None
369+ ]
374370
375371
376372def fetch_key_performance_issue_groups (ctx : OrganizationReportContext ):
0 commit comments