Skip to content

Commit 60e60d7

Browse files
committed
contest: backend: support querying stability and device info
Basic queries of stability and device info. Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 8e2d457 commit 60e60d7

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

contest/backend/query.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,3 +155,38 @@ def remotes():
155155
print(f"Query for remotes: {str(t2-t1)}")
156156

157157
return rows
158+
159+
160+
@app.route('/stability')
161+
def stability():
162+
# auto = query only tests which NIPA ignores based on stability
163+
auto = request.args.get('auto')
164+
165+
where = ""
166+
if auto == "y" or auto == '1' or auto == 't':
167+
where = "WHERE autoignore = true";
168+
elif auto == "n" or auto == '0' or auto == 'f':
169+
where = "WHERE autoignore = false";
170+
171+
with psql.cursor() as cur:
172+
cur.execute(f"SELECT * FROM stability {where}")
173+
174+
columns = [desc[0] for desc in cur.description]
175+
rows = cur.fetchall()
176+
# Convert each row to a dictionary with column names as keys
177+
data = [{columns[i]: value for i, value in enumerate(row)} for row in rows]
178+
179+
return data
180+
181+
182+
@app.route('/device-info')
183+
def dev_info():
184+
with psql.cursor() as cur:
185+
cur.execute(f"SELECT * FROM devices_info")
186+
187+
columns = [desc[0] for desc in cur.description]
188+
rows = cur.fetchall()
189+
# Convert each row to a dictionary with column names as keys
190+
data = [{columns[i]: value for i, value in enumerate(row)} for row in rows]
191+
192+
return data

0 commit comments

Comments
 (0)