-
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 issue with scheduled queries #7111
Conversation
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.
Tested this manually, seems to check out
0d863b8
to
f1b6be0
Compare
@arikfr Any idea if this will interact with the scheduled queries hash issue you were looking at yesterday? |
redash/models/__init__.py
Outdated
if all(value is None for value in query.schedule.values()): | ||
continue |
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.
What's this for?
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.
It's been a little while since I looked at this, but I think this is the answer:
The only way to check whether a query doesn't have a refresh schedule is to ensure that everything in query.schedule.values()
is None. For example, interval, until, time are all keys in the query.schedule
. It's possible to have a query refresh schedule when just one of these keys is not None.
If a query doesn't have a refresh schedule, then we can just continue to the next query in the loop.
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.
When a query does not have a schedule then the schedule value is null (or empty). It's possible there is some edge case scenario that might keep schedule object with empty values, but I would assume it's not common?
To keep the code maintainable I would rather avoid this change in this PR and if you still feel it's necessary let's bring it back in a separate one and have the discussion there (and potentially add tests for this case).
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.
I think this is worth double checking. I could be mistaken, but I remember this edge case popping up during my testing. Perhaps if a query had a schedule and then that schedule was later removed?
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.
Sounds like we'll need to create a follow up PR to this one if/when we merge this. 😄
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.
I found out that we have an explicit test case for this (schedule object with all values being None). I don't know if this is to cover some case that won't happen anymore, but just to be on the safe side I kept this logic + added a comment to explain.
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.
One last review. Please let us know if you have the bandwidth to apply the changes. Thanks!
redash/models/__init__.py
Outdated
if all(value is None for value in query.schedule.values()): | ||
continue |
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.
When a query does not have a schedule then the schedule value is null (or empty). It's possible there is some edge case scenario that might keep schedule object with empty values, but I would assume it's not common?
To keep the code maintainable I would rather avoid this change in this PR and if you still feel it's necessary let's bring it back in a separate one and have the discussion there (and potentially add tests for this case).
I lost access to the VM that I was using over the summer for Redash dev work unfortunately, so I think it's easiest if someone else applies the changes. |
@ezraodio1 If you need a new VM for doing Redash dev work on, then I'm happy to spin one up for you. Would that be useful? 😄 |
I'm taking a tough course load right, so I'm pretty busy. I'd definitely be interested after this semester ends, though. I'll try to spin up a new VM for myself. |
No worries. Keep it in mind as an option if/when it'd be useful. Good luck with your course load, hopefully it all goes really well. 😄 |
@arikfr Should we merge this PR as-is, or do you want to modify it a bit first? Asking because @ezraodio1 doesn't have the bandwidth to make changes at present. |
@arikfr Should this be merged now? 😄 |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #7111 +/- ##
==========================================
- Coverage 64.15% 64.14% -0.01%
==========================================
Files 162 162
Lines 13295 13341 +46
Branches 1883 1893 +10
==========================================
+ Hits 8529 8558 +29
- Misses 4432 4450 +18
+ Partials 334 333 -1
|
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.
Eric already approved the previous revision of this. 😄
What type of PR is this?
Description
There's currently an issue in Redash where some queries fail to refresh on their schedule. This happens when the query has no
latest_query_data
, which makesretrieved_at = None
, which makes it so the query never gets added tooutdated_queries
. This PR fixes that.The problem can be reproduced by running the unit test that's part of this PR (without making the fix first, of course)
How is this tested?
Related Tickets & Documents
Mobile & Desktop Screenshots/Recordings (if there are UI changes)