From de0b3c84d57d92d35d3f91ea33cb07fff3b04962 Mon Sep 17 00:00:00 2001 From: "Matthieu Baerts (NGI0)" Date: Wed, 12 Jun 2024 13:04:49 +0200 Subject: [PATCH] system-status: db: reverse order The list we get from the DB is reversed, to be able to easily limit it to 40 entries. To present the data in the right order in the JSON, we need to reverse them again. The UI could also reverse them, but it sounds better to write the data in the right order instead. Signed-off-by: Matthieu Baerts (NGI0) --- system-status.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system-status.py b/system-status.py index cc9421e..d852506 100755 --- a/system-status.py +++ b/system-status.py @@ -180,7 +180,7 @@ def add_db(result, cfg): with psql.cursor() as cur: cur.execute(f"SELECT ts,size FROM {tbl} ORDER BY id DESC LIMIT 40") - result["db"]["data"] = [ {'ts': t.isoformat(), 'size': s} for t, s in cur.fetchall() ] + result["db"]["data"] = [ {'ts': t.isoformat(), 'size': s} for t, s in reversed(cur.fetchall()) ] def main():