Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.

Commit de9265f

Browse files
committed
fix: rename some of the SQL aliases
1 parent 811a290 commit de9265f

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

utils/test_results.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,12 @@ def generate_base_query(
112112
[
113113
f"rt.{order_field}"
114114
if order_field in {"name", "computed_name"}
115-
else f"foo.{order_field}"
115+
else f"results.{order_field}"
116116
for order_field in ordering
117117
]
118118
)
119119
order_by = ",".join(
120-
[f"bar.{order} {ordering_direction.name}" for order in ordering]
120+
[f"with_cursor.{order} {ordering_direction.name}" for order in ordering]
121121
)
122122

123123
params: list[int | str | tuple[str, ...] | None] = [
@@ -149,7 +149,7 @@ def generate_base_query(
149149
{ "and rt.testsuite in %s" if testsuites else ""}
150150
{ "and rt.name like %s" if term else ""}
151151
),
152-
cte1 as (
152+
failure_rate_cte as (
153153
select
154154
test_id,
155155
CASE
@@ -161,48 +161,48 @@ def generate_base_query(
161161
ELSE SUM(flaky_fail_count)::float / (SUM(pass_count) + SUM(fail_count))
162162
END as flake_rate,
163163
MAX(latest_run) as updated_at,
164-
AVG(rd.avg_duration_seconds) AS avg_duration,
164+
AVG(avg_duration_seconds) AS avg_duration,
165165
SUM(fail_count) as total_fail_count,
166166
SUM(pass_count) as total_pass_count,
167167
SUM(skip_count) as total_skip_count
168-
from base_cte rd
168+
from base_cte
169169
group by test_id
170170
),
171-
cte2 as (
171+
commits_where_fail_cte as (
172172
select test_id, array_length((array_agg(distinct unnested_cwf)), 1) as failed_commits_count from (
173173
select test_id, commits_where_fail as cwf
174-
from base_cte rd
174+
from base_cte
175175
where array_length(commits_where_fail,1) > 0
176176
) as foo, unnest(cwf) as unnested_cwf group by test_id
177177
),
178-
cte3 as (
179-
select rd.test_id, last_duration_seconds from base_cte rd
178+
last_duration_cte as (
179+
select base_cte.test_id, last_duration_seconds from base_cte
180180
join (
181181
select
182182
test_id,
183183
max(created_at) as created_at
184-
from base_cte base
184+
from base_cte
185185
group by test_id
186-
) as foo
187-
on rd.created_at = foo.created_at
186+
) as latest_rollups
187+
on base_cte.created_at = latest_rollups.created_at
188188
)
189189
190190
select * from (
191191
select
192192
rt.name,
193193
rt.computed_name,
194-
foo.*,
194+
results.*,
195195
row({order}) as _cursor
196196
from
197197
(
198-
select cte1.*, coalesce(cte2.failed_commits_count, 0) as commits_where_fail, cte3.last_duration_seconds as last_duration
199-
from cte1
200-
full outer join cte2 using (test_id)
201-
full outer join cte3 using (test_id)
202-
) as foo join reports_test rt on foo.test_id = rt.id
203-
) as bar
204-
{"where bar._cursor > %s" if after else ""}
205-
{"where bar._cursor < %s" if before else ""}
198+
select failure_rate_cte.*, coalesce(commits_where_fail_cte.failed_commits_count, 0) as commits_where_fail, last_duration_cte.last_duration_seconds as last_duration
199+
from failure_rate_cte
200+
full outer join commits_where_fail_cte using (test_id)
201+
full outer join last_duration_cte using (test_id)
202+
) as results join reports_test rt on results.test_id = rt.id
203+
) as with_cursor
204+
{"where with_cursor._cursor > %s" if after else ""}
205+
{"where with_cursor._cursor < %s" if before else ""}
206206
order by {order_by}
207207
limit %s
208208
"""

0 commit comments

Comments
 (0)