Skip to content

Commit

Permalink
system-status: db: reverse order
Browse files Browse the repository at this point in the history
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) <[email protected]>
  • Loading branch information
matttbe authored and kuba-moo committed Jun 12, 2024
1 parent cb64a11 commit de0b3c8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion system-status.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit de0b3c8

Please sign in to comment.