|
1 |
| --- TODO (huydhn): This query tracks the number of red commits on HUD KPIs page. This |
2 |
| --- is not the most efficient query around both in term of speed and memory usage. So, |
3 |
| --- a good BE task is to re-write this in a more efficient way, HUD code is also |
4 |
| --- subjected to change if need be |
5 |
| -WITH join_with_workflow_run AS ( |
6 |
| - -- Do the join with workflow_run, then workflow_job to avoid OOM |
7 |
| - SELECT |
8 |
| - w.id AS id, |
| 1 | +-- huydhn: This query tracks the number of red commits on HUD KPIs page. |
| 2 | +WITH pushes AS ( -- very selective |
| 3 | + select |
9 | 4 | p.head_commit. 'timestamp' AS time,
|
10 | 5 | p.head_commit. 'id' AS sha
|
11 |
| - FROM |
| 6 | + from |
12 | 7 | default .push p FINAL
|
13 |
| - JOIN default .workflow_run w FINAL ON w.head_commit. 'id' = p.head_commit. 'id' |
14 |
| - WHERE |
15 |
| - ( |
16 |
| - -- Limit it to workflows which block viable/strict upgrades |
17 |
| - has({workflowNames: Array(String) }, lower(w.name)) |
18 |
| - OR w.name like 'linux-binary%' |
19 |
| - ) |
20 |
| - AND w.event != 'workflow_run' -- Filter out worflow_run-triggered jobs, which have nothing to do with the SHA |
21 |
| - AND p.ref = 'refs/heads/main' |
22 |
| - AND p.repository. 'owner'.'name' = 'pytorch' |
23 |
| - AND p.repository. 'name' = 'pytorch' |
24 |
| - AND p.head_commit. 'timestamp' >= {startTime: DateTime64(3) } |
25 |
| - AND p.head_commit. 'timestamp' < {stopTime: DateTime64(3) } |
| 8 | + where |
| 9 | + p.ref = 'refs/heads/main' |
| 10 | + and p.repository. 'owner'.'name' = 'pytorch' |
| 11 | + and p.repository. 'name' = 'pytorch' |
| 12 | + and p.head_commit. 'timestamp' >= {startTime: DateTime64(3) } |
| 13 | + and p.head_commit. 'timestamp' < {stopTime: DateTime64(3) } |
26 | 14 | ),
|
27 | 15 | all_jobs AS (
|
28 | 16 | SELECT
|
29 |
| - w.time AS time, |
| 17 | + p.time AS time, |
30 | 18 | j.conclusion AS conclusion,
|
31 |
| - w.sha AS sha, |
| 19 | + j.head_sha AS sha, |
32 | 20 | ROW_NUMBER() OVER(
|
33 | 21 | PARTITION BY j.name,
|
34 |
| - w.sha |
| 22 | + j.head_sha |
35 | 23 | ORDER BY
|
36 | 24 | j.run_attempt DESC
|
37 | 25 | ) AS row_num
|
38 | 26 | FROM
|
39 |
| - join_with_workflow_run w |
40 |
| - JOIN default .workflow_job j FINAL ON w.id = j.run_id |
| 27 | + default .workflow_job j FINAL |
| 28 | + join pushes p FINAL on j.head_sha = p.sha |
41 | 29 | WHERE
|
42 |
| - j.name != 'ciflow_should_run' |
| 30 | + j.id in ( |
| 31 | + SELECT id FROM materialized_views.workflow_job_by_head_sha |
| 32 | + WHERE head_sha in (SELECT distinct p.sha FROM pushes p) |
| 33 | + ) |
| 34 | + AND j.workflow_event != 'workflow_run' -- Filter out worflow_run-triggered jobs, which have nothing to do with the SHA |
| 35 | + AND ( |
| 36 | + -- Limit it to jobs which block viable/strict upgrades |
| 37 | + has({workflowNames: Array(String) }, lower(j.workflow_name)) |
| 38 | + OR j.workflow_name like 'linux-binary%' |
| 39 | + ) |
| 40 | + AND j.name != 'ciflow_should_run' |
43 | 41 | AND j.name != 'generate-test-matrix'
|
44 | 42 | AND j.name NOT LIKE '%rerun_disabled_tests%'
|
45 | 43 | AND j.name NOT LIKE '%unstable%'
|
|
0 commit comments