Skip to content

fix get unique timezones #896

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

fix get unique timezones #896

wants to merge 4 commits into from

Conversation

beedub
Copy link

@beedub beedub commented May 14, 2025

the previous query did not actually get distinct timezones

@beedub beedub force-pushed the master branch 2 times, most recently from 155d83e to aabbaad Compare May 14, 2025 17:46
@beedub beedub changed the title fix _get_distinct_timezone fix get unique timezones May 14, 2025
@cclauss
Copy link
Contributor

cclauss commented May 14, 2025

Please run pre-commit on django_celery_beat/schedulers.py

@beedub
Copy link
Author

beedub commented May 14, 2025

@cclauss updated

Copy link

codecov bot commented May 15, 2025

Codecov Report

Attention: Patch coverage is 75.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 87.99%. Comparing base (70d381b) to head (2c23b14).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
django_celery_beat/schedulers.py 75.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #896      +/-   ##
==========================================
- Coverage   88.19%   87.99%   -0.20%     
==========================================
  Files          32       32              
  Lines        1008     1008              
  Branches      105      105              
==========================================
- Hits          889      887       -2     
- Misses        101      102       +1     
- Partials       18       19       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@auvipy
Copy link
Member

auvipy commented May 17, 2025

@alirafiei75 please take a look

@auvipy auvipy requested review from auvipy and Copilot May 17, 2025 08:33
Copilot

This comment was marked as outdated.

@auvipy auvipy requested a review from Copilot May 17, 2025 08:35
Copy link

@Copilot Copilot AI left a 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 fixes an issue with retrieving unique timezones from the CrontabSchedule by updating the query logic and the corresponding test.

  • Updated the scheduler method to use _get_unique_timezones instead of _get_unique_timezone_names.
  • Added a unit test to ensure that the unique timezone retrieval returns the expected distinct timezones.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
t/unit/test_schedulers.py Adds a unit test validating that unique timezones are correctly returned.
django_celery_beat/schedulers.py Updates the unique timezone query and removes the old method.

Copy link
Member

@auvipy auvipy left a comment

Choose a reason for hiding this comment

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

can we get additional tests for this?

@beedub
Copy link
Author

beedub commented May 17, 2025

@auvipy can you suggest what additional tests you want here?

Copy link
Member

@auvipy auvipy left a comment

Choose a reason for hiding this comment

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

there are failing tests now, can you fix them?

beedub added 2 commits May 18, 2025 08:48
the previous query did not actually get distinct timezones
@auvipy
Copy link
Member

auvipy commented May 18, 2025

The rebase didn’t work. Please make it errorless again

this tested for string timezones, which were not possible
Copy link
Member

@auvipy auvipy left a comment

Choose a reason for hiding this comment

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

Why are we removing the tests?

@beedub
Copy link
Author

beedub commented May 19, 2025

it's the same test as the one below test_timezone_offset_with_zoneinfo_object_param, except that it tests with string timezone names, which as discussed, is not possible given that timezone always returns ZoneInfo

@@ -1663,31 +1678,6 @@ def setup_method(self):
def teardown_method(self):
patch.stopall()

@patch("django_celery_beat.schedulers.aware_now")
Copy link
Member

Choose a reason for hiding this comment

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

can we add more tests which also improve the test coverage? and there is no regression introduced?

@beedub
Copy link
Author

beedub commented May 20, 2025

if you're referring to the codecov note, then i would guess it's b/c the tests only run with sqlite. can you confirm?

if so, i don't have have the bandwidth to update the test suite to also run a build with non-sqlite (eg. postgres). i can remove the sqlite/non-sqlite conditional in that code even though it'll be less performant, but i think it'll increase the codecov by virtue of not having a non-tested branch

re: regressions, there are existing tests from the original PR that introduced this change that should cover regressions. this change is a performance improvement

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.

4 participants