-
Notifications
You must be signed in to change notification settings - Fork 186
Fix: January bin dates being treated as past during December #1787
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
base: master
Are you sure you want to change the base?
Conversation
Some councils return January collection dates using the current year during December. For example, Bromley just lists the day and month, which is then interpreted as the current year rather than next year. This causes valid upcoming collections to be dropped. This change corrects the year in Dec → Jan rollover cases.
📝 WalkthroughWalkthroughA rollover-year correction has been added to the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
| if ( | ||
| collection_date < current_date | ||
| and current_date.month == 12 | ||
| and collection_date.month == 1 | ||
| ): | ||
| collection_date = collection_date.replace(year=current_date.year + 1) | ||
| _LOGGER.debug( | ||
| f"{LOG_PREFIX} Corrected rollover year for '{bin_type}' to {collection_date}" | ||
| ) | ||
|
|
||
|
|
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.
🧩 Analysis chain
🏁 Script executed:
# First, let's see the actual code around lines 416-426
head -n 430 custom_components/uk_bin_collection/__init__.py | tail -n 40Repository: robbrad/UKBinCollectionData
Length of output: 1656
🏁 Script executed:
# Search for test files related to this component
find . -name "*.py" -path "*/test*" -type f | head -20Repository: robbrad/UKBinCollectionData
Length of output: 1208
🏁 Script executed:
# Look for tests that might cover the process_bin_data method
rg -l "process_bin_data" --type pyRepository: robbrad/UKBinCollectionData
Length of output: 230
🏁 Script executed:
# Check if there are any tests for December/January scenarios
rg -n "december|january|rollover|year" --type py -i | grep -i testRepository: robbrad/UKBinCollectionData
Length of output: 2565
🏁 Script executed:
# Examine the test_init.py file to see if there are tests for process_bin_data
cat custom_components/uk_bin_collection/tests/test_init.pyRepository: robbrad/UKBinCollectionData
Length of output: 9915
🏁 Script executed:
# Also check for any PR or issue references in git history
git log --oneline --all | grep -i "january\|rollover\|december\|year" | head -20Repository: robbrad/UKBinCollectionData
Length of output: 693
🏁 Script executed:
# Search for the process_bin_data method definition to understand its signature
rg -n "def process_bin_data" custom_components/uk_bin_collection/__init__.py -A 5Repository: robbrad/UKBinCollectionData
Length of output: 371
🏁 Script executed:
# Check the exact commit that added the rollover fix
git show 0301ad5 --statRepository: robbrad/UKBinCollectionData
Length of output: 27677
🏁 Script executed:
# Look at the changes in that commit
git show 0301ad5Repository: robbrad/UKBinCollectionData
Length of output: 50385
🏁 Script executed:
# Search for any December/January or rollover specific tests in test_init.py
grep -n "december\|january\|rollover\|2025\|2026" custom_components/uk_bin_collection/tests/test_init.py -iRepository: robbrad/UKBinCollectionData
Length of output: 120
🏁 Script executed:
# Check if the logic is indeed placed before the >= current_date filter
sed -n '416,435p' custom_components/uk_bin_collection/__init__.pyRepository: robbrad/UKBinCollectionData
Length of output: 903
The December→January rollover logic correctly addresses the issue, but add unit tests to ensure the edge case is covered.
The three-condition check is properly implemented and placed before the future date filter. However, the test suite needs dedicated test cases for the December→January transition:
- December 24, 2025 with "06/01/2025" should become January 6, 2026
- December 31, 2025 with "01/01/2025" should become January 1, 2026
- January 15, 2026 with "20/01/2026" should remain unchanged
- December 15, 2025 with "20/12/2025" should remain unchanged
These scenarios should be added to test_init.py to prevent regression and validate the fix works as intended.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1787 +/- ##
==========================================
- Coverage 86.81% 86.67% -0.15%
==========================================
Files 9 9
Lines 1138 1141 +3
==========================================
+ Hits 988 989 +1
- Misses 150 152 +2 ☔ View full report in Codecov by Sentry. |
Some councils return January collection dates using the current year during December. For example, Bromley just lists the day and month, which is then interpreted as the current year rather than next year. This causes valid upcoming collections to be dropped. This change corrects the year in Dec → Jan rollover cases.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.