Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

system-status: db: reverse order #27

Merged
merged 1 commit into from
Jun 12, 2024
Merged

Conversation

matttbe
Copy link
Member

@matttbe matttbe commented Jun 12, 2024

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.

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]>
@matttbe matttbe requested a review from kuba-moo June 12, 2024 11:05
@@ -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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just remove the DESC here, no?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but then it will take the 40 first ones, instead of the 40 last ones. If you want the last 40 ones in the right order, you need to use an offset, which cannot be negative, etc. :) (or maybe they have a new attribute?)
I found it easier and clearer to do it like that (but I forgot the reverse...)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, right!

@kuba-moo kuba-moo merged commit de0b3c8 into linux-netdev:main Jun 12, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants