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

Fix: sorting queries by schedule was resulting in a wrong order #4954

Merged
merged 5 commits into from
Jul 7, 2020

Conversation

leini-db
Copy link
Contributor

@leini-db leini-db commented Jun 7, 2020

What type of PR is this? (check all applicable)

  • Bug Fix

Description

sorting on schedule was not working. it use schedule which is an object to compare. by default, it's converted to string value. so 1000 is sorted ahead of 60

Related Tickets & Documents

Mobile & Desktop Screenshots/Recordings (if there are UI changes)

@arikfr arikfr changed the title fix schedule sorting issue Fix: sorting queries by schedule was resulting in a wrong order Jun 18, 2020
@arikfr
Copy link
Member

arikfr commented Jun 18, 2020

I was about to merge this, but then I realized that this is only half of the solution: this fixes sorting on the frontend, but the backend sorting remains broken (for similar reasons). You can see what I mean in the preview instance:

https://deploy-preview-4954--redash-preview.netlify.app/queries?order=schedule&page=1&page_size=5

You will notice that when we limit the page size to 5 queries, a query scheduled to refresh every 30 days shows up before queries scheduled to refresh every minute.

I'm not sure how hard it is to fix on the backend, it's possible you can define a json_cast_property property (example) that extracts the interval value and then use it for sorting (mapping defined here).

We do the same for the active_at value on the users page, so it's likely to work. I just don't know what happens when the schedule value is null instead of a json object.

@leini-db
Copy link
Contributor Author

leini-db commented Jun 18, 2020 via email

Copy link
Member

@arikfr arikfr left a comment

Choose a reason for hiding this comment

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

Looking good. Just a small thing to fix in the comment.

Comment on lines 117 to 119
A SQLAlchemy index property that is able to cast the
entity attribute as the specified cast type. Useful
for JSON and JSONB colums for easier querying/filtering.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
A SQLAlchemy index property that is able to cast the
entity attribute as the specified cast type. Useful
for JSON and JSONB colums for easier querying/filtering.
A SQLAlchemy index property that is able to cast the
entity attribute as the specified cast type. Useful
for PseudoJSON colums for easier querying/filtering.

@arikfr arikfr merged commit 878b297 into getredash:master Jul 7, 2020
@arikfr
Copy link
Member

arikfr commented Jul 7, 2020

Merged 👍 Congrats on your first PR :-)

andrewdever pushed a commit to andrewdever/redash that referenced this pull request Oct 5, 2020
…edash#4954)

* fix schedule sorting issue

* style change

* Update to meet code style.

* move the schedule sort to backend

* mod comment

Co-authored-by: Arik Fraimovich <arik@arikfr.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants