-
Notifications
You must be signed in to change notification settings - Fork 460
refactor: use in operator instead of regex operator in crontab query to fix mssql regression #900
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
refactor: use in operator instead of regex operator in crontab query to fix mssql regression #900
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #900 +/- ##
==========================================
- Coverage 88.24% 87.67% -0.57%
==========================================
Files 32 32
Lines 1012 1014 +2
Branches 105 82 -23
==========================================
- Hits 893 889 -4
- Misses 101 107 +6
Partials 18 18 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Pull Request Overview
This PR refactors the _get_crontab_exclude_query
method in DatabaseScheduler
to replace a regex-based hour filter with an explicit __in
lookup over a generated list of valid hour strings.
- Removed the
numeric_hour_pattern
regex filter. - Introduced a
valid_hours
list combining non-padded and zero-padded representations for hours 0–23. - Updated the queryset to use
hour__in=valid_hours
instead ofhour__regex
.
Comments suppressed due to low confidence (1)
django_celery_beat/schedulers.py:323
- Add unit tests to verify that the filter correctly matches both padded and non-padded hour values in the database, ensuring no valid entries are missed.
hour__in=valid_hours
Co-authored-by: Copilot <[email protected]>
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.
can we verify / fix this with modified tests please? the copilot suggestion seems to break the tests
=================================== FAILURES =================================== self = <t.unit.test_schedulers.test_DatabaseScheduler object at 0x7f2fbbbd74d0>
E AssertionError: UTC outside window task should be excluded t/unit/test_schedulers.py:1133: AssertionError |
yes I will. the copilot suggestion was wrong |
Co-authored-by: Copilot <[email protected]>
As we need both padded and non-padded hours ("1" and "01"), we cannot do it in just one list comprehension, or if we do it would not be readable i think |
can you apply the improvement and also add unit tests to verify this please? |
Yup, that looks better |
Description
This pull request refactors _get_crontab_exclude_query method of DatabaseScheduler class to use a list of valid numeric hours for crontab query instead of regex pattern
Related Issues
Fixes: #897