You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: contest/backend/query.py
+13-8
Original file line number
Diff line number
Diff line change
@@ -35,17 +35,17 @@ def branches():
35
35
returnrows
36
36
37
37
38
-
#SELECT branch,branch_date,count(*),remote FROM results GROUP BY branch,branch_date,remote ORDER BY branch_date DESC LIMIT 510;
39
-
40
-
defbranches_to_rows(br_cnt, remote):
38
+
defbranches_to_rows(br_cnt, remote, br_pfx=None):
41
39
globalpsql
42
40
43
41
cnt=0
44
42
withpsql.cursor() ascur:
45
-
ifremote:
46
-
q=f"SELECT branch,count(*),branch_date,remote FROM results GROUP BY branch,branch_date,remote ORDER BY branch_date DESC LIMIT {br_cnt}"
47
-
else:
48
-
q=f"SELECT branch,count(*),branch_date FROM results GROUP BY branch,branch_date ORDER BY branch_date DESC LIMIT {br_cnt}"
43
+
remote_k=",remote"ifremoteelse""
44
+
# Slap the -2 in here as the first letter of the date, to avoid prefix of prefix matches
45
+
pfx_flt=f"WHERE branch LIKE '{br_pfx}-2%' "ifbr_pfxelse""
46
+
47
+
q=f"SELECT branch,count(*),branch_date{remote_k} FROM results {pfx_flt} GROUP BY branch,branch_date{remote_k} ORDER BY branch_date DESC LIMIT {br_cnt}"
48
+
49
49
cur.execute(q)
50
50
forrincur.fetchall():
51
51
cnt+=r[1]
@@ -108,7 +108,12 @@ def results():
108
108
ifnotbr_cnt:
109
109
br_cnt=10
110
110
111
-
limit=branches_to_rows(br_cnt, remote)
111
+
br_pfx=request.args.get('br-pfx')
112
+
ifbr_pfx:
113
+
# Slap the -2 in here as the first letter of the date, to avoid prefix of prefix matches
0 commit comments