-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Conversation
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 We do the same for the |
oops, Let me look into this.
Lei
…On Thu, Jun 18, 2020 at 12:46 AM Arik Fraimovich ***@***.***> wrote:
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
<https://github.com/getredash/redash/blob/98a5154345307737c9faa012547c1529a56f2f8d/redash/models/users.py#L102-L104>)
that extracts the interval value and then use it for sorting (mapping
defined here
<https://github.com/getredash/redash/blob/98a5154345307737c9faa012547c1529a56f2f8d/redash/handlers/queries.py#L40-L41>
).
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.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#4954 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/APUT5EPVGRIR7H2A6WTG3GTRXHA6RANCNFSM4NXYGCGQ>
.
|
There was a problem hiding this 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.
redash/models/types.py
Outdated
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
Merged 👍 Congrats on your first PR :-) |
…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>
What type of PR is this? (check all applicable)
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)