@@ -193,11 +193,7 @@ def replace_astral(log_list):
193
193
yield item
194
194
195
195
196
- def get_group_results_legacy (repository , push ):
197
- """
198
- Legacy implementation - preserved for testing and comparison.
199
- Performance: ~3.3 seconds average.
200
- """
196
+ def get_group_results (repository , push ):
201
197
groups = Group .objects .filter (
202
198
job_logs__job__push__revision = push .revision ,
203
199
job_logs__job__push__repository = repository ,
@@ -215,63 +211,3 @@ def get_group_results_legacy(repository, push):
215
211
)
216
212
217
213
return by_task_id
218
-
219
-
220
- def get_group_results (repository , push ):
221
- """
222
- OPTIMIZED IMPLEMENTATION - Best performing non-cached query.
223
-
224
- Performance: ~0.129s (27% faster than legacy 0.176s)
225
-
226
- This implementation uses an optimized SQL query starting from the job table
227
- for the best join performance with the new database indexes.
228
-
229
- RECOMMENDED DATABASE INDEXES (already applied):
230
-
231
- -- Composite indexes for optimal query performance
232
- CREATE INDEX CONCURRENTLY idx_group_status_composite
233
- ON group_status(status, job_log_id, group_id);
234
-
235
- CREATE INDEX CONCURRENTLY idx_job_push_id
236
- ON job(push_id);
237
-
238
- CREATE INDEX CONCURRENTLY idx_job_log_job_id
239
- ON job_log(job_id);
240
-
241
- CREATE INDEX CONCURRENTLY idx_taskcluster_metadata_job_id
242
- ON taskcluster_metadata(job_id);
243
-
244
- CREATE INDEX CONCURRENTLY idx_push_revision_repo
245
- ON push(revision, repository_id);
246
- """
247
- from django .db import connection
248
-
249
- ok_status = GroupStatus .OK
250
-
251
- query = """
252
- SELECT
253
- tcm.task_id,
254
- g.name,
255
- gs.status
256
- FROM job j
257
- INNER JOIN taskcluster_metadata tcm ON j.id = tcm.job_id
258
- INNER JOIN job_log jl ON j.id = jl.job_id
259
- INNER JOIN group_status gs ON jl.id = gs.job_log_id
260
- INNER JOIN "group" g ON gs.group_id = g.id
261
- WHERE j.push_id = %s
262
- AND gs.status IN (%s, %s)
263
- ORDER BY tcm.task_id
264
- """
265
-
266
- by_task_id = {}
267
-
268
- with connection .cursor () as cursor :
269
- cursor .execute (query , [push .id , GroupStatus .OK , GroupStatus .ERROR ])
270
- rows = cursor .fetchall ()
271
-
272
- for task_id , group_name , status in rows :
273
- if task_id not in by_task_id :
274
- by_task_id [task_id ] = {}
275
- by_task_id [task_id ][group_name ] = status == ok_status
276
-
277
- return by_task_id
0 commit comments