Skip to content

Conversation

@liam-london
Copy link

@liam-london liam-london commented Dec 24, 2025

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

  • Bug Fixes
    • Fixed bin collection date handling for collections that cross year boundaries. When viewing upcoming collections in December scheduled for January, dates now correctly reflect the following year.

✏️ Tip: You can customize this high-level summary in your review settings.

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.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 24, 2025

📝 Walkthrough

Walkthrough

A rollover-year correction has been added to the process_bin_data function. When a bin collection date is in the past but crosses a year boundary (December transitioning to January), the code now adjusts the year forward and logs the correction before determining the next collection date.

Changes

Cohort / File(s) Summary
Year-rollover correction logic
custom_components/uk_bin_collection/__init__.py
Added conditional logic in process_bin_data to detect and correct bin collection dates that span year boundaries (December month → January month), bumping the year forward with logging to capture the adjustment.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

Suggested reviewers

  • dp247

Poem

🐰 A hop, a skip, through December's last call,
When bins meet the new year, we don't miss at all!
The dates now roll forward with hop and a bound,
Year-end transitions? No confusion is found! ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main fix: correcting January bin collection dates that were incorrectly treated as past dates during December, matching the core objective of the pullrequest.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 83cce53 and 0301ad5.

📒 Files selected for processing (1)
  • custom_components/uk_bin_collection/__init__.py

Comment on lines +416 to +426
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}"
)


Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 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 40

Repository: robbrad/UKBinCollectionData

Length of output: 1656


🏁 Script executed:

# Search for test files related to this component
find . -name "*.py" -path "*/test*" -type f | head -20

Repository: 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 py

Repository: 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 test

Repository: 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.py

Repository: 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 -20

Repository: 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 5

Repository: robbrad/UKBinCollectionData

Length of output: 371


🏁 Script executed:

# Check the exact commit that added the rollover fix
git show 0301ad5 --stat

Repository: robbrad/UKBinCollectionData

Length of output: 27677


🏁 Script executed:

# Look at the changes in that commit
git show 0301ad5

Repository: 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 -i

Repository: 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__.py

Repository: 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
Copy link

codecov bot commented Jan 4, 2026

Codecov Report

❌ Patch coverage is 33.33333% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.67%. Comparing base (83cce53) to head (0301ad5).

Files with missing lines Patch % Lines
custom_components/uk_bin_collection/__init__.py 33.33% 2 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

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.

1 participant