Skip to content

Conversation

@jimgolfgti
Copy link
Contributor

@jimgolfgti jimgolfgti commented Dec 7, 2025

Rushcliffe BC have updated its self-service response to contain an additional collection type and collection date.

e.g.

Your next grey bin collections will be 16/12/2025 and 30/12/2025
Your next blue bin collections will be 09/12/2025 and 23/12/2025
Your next garden waste bin collections will be 09/12/2025 and 20/01/2026
Your next glass (purple lid) bin collections will be 16/12/2025 and 27/01/2026

This PR updates the regex to handle the change in presentation.

We now include the additional collection date in the result data.

Verified that the behaviour test for RushcliffeBoroughCouncil now passes.

Summary by CodeRabbit

  • New Features

    • Rushcliffe Borough Council bin collection schedules now capture multiple collection dates per bin type, providing more detailed scheduling information.
  • Bug Fixes

    • Improved error handling and data processing robustness for collection schedule retrieval.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 7, 2025

Walkthrough

The Rushcliffe Borough Council parser was modified to extract and process two collection dates per bin type instead of one. The regex pattern now captures dual dates, creating separate entries for each date. Exception handling was strengthened with proper driver cleanup, and sorting was deferred until after all results are processed. An unused import was removed.

Changes

Cohort / File(s) Summary
Bin Collection Parser Enhancement
uk_bin_collection/uk_bin_collection/councils/RushcliffeBoroughCouncil.py
Modified regex to extract two collection dates per bin type; generates two separate bin entries per parsed result; moved sorting after result accumulation; enhanced exception handling with driver cleanup in finally block; removed unused string import

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Areas requiring attention:
    • Verify the regex pattern correctly captures both collection dates for all expected bin types
    • Confirm the dual-entry logic doesn't introduce duplicate or incorrect records
    • Test exception handling to ensure Selenium driver is properly closed in all failure paths
    • Validate that post-processing sort order is correct and matches expected output format

Suggested reviewers

  • dp247

Poem

🐰 Two dates now bloom where one stood before,
The Rushcliffe parser sorts its treasured score,
With twice the collection and cleanup so fine,
The driver quits gracefully—exceptions align! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix:Rushcliffe BC broken scraping' clearly identifies the main change: fixing a broken scraper for Rushcliffe Borough Council. It's concise and specific about the primary modification.
✨ 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: 0

🧹 Nitpick comments (2)
uk_bin_collection/uk_bin_collection/councils/RushcliffeBoroughCouncil.py (2)

89-103: Two-date parsing logic is correct; small duplication and linter concerns

Functionally this does what you need: both dates are parsed and emitted as separate entries with the same type, so downstream consumers will see two upcoming collections per bin.

Two minor points you may want to tidy up:

  1. Duplication – you could reduce repetition by looping over the two date fields instead of duplicating the append block, e.g.:
-        collection_one = datetime.strptime(result[1], "%d/%m/%Y")
-        data["bins"].append(
-            {
-                "type": result[0],
-                "collectionDate": collection_one.strftime(date_format),
-            }
-        )
-        collection_two = datetime.strptime(result[2], "%d/%m/%Y")
-        data["bins"].append(
-            {
-                "type": result[0],
-                "collectionDate": collection_two.strftime(date_format),
-            }
-        )
+        for raw_date in (result[1], result[2]):
+            collection = datetime.strptime(raw_date, "%d/%m/%Y")
+            data["bins"].append(
+                {
+                    "type": result[0],
+                    "collectionDate": collection.strftime(date_format),
+                }
+            )
  1. Ruff F405 warningsdatetime and date_format are pulled in via from ...common import *, which is fine at runtime if common exports them, but static analysis tools complain. You could either:
    • Add explicit imports for clarity, e.g. from datetime import datetime at the top and import date_format explicitly from common, or
    • Add targeted # noqa: F405 comments on these uses if the star import pattern is intentional across the project.

105-109: Sorting after appending all bin entries is sensible; consider avoiding re-parsing

Deferring the sort until after all entries are appended is a good change and ensures a fully chronological list. Since you already normalise dates via strftime(date_format), you’re forced to re-parse here; if you ever switch to storing YYYY-MM-DD strings or keep a parallel datetime field, you could drop the extra strptime call. Not urgent, just a potential micro-optimisation.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 37c8a80 and e0c484d.

📒 Files selected for processing (1)
  • uk_bin_collection/uk_bin_collection/councils/RushcliffeBoroughCouncil.py (1 hunks)
🧰 Additional context used
🪛 Ruff (0.14.7)
uk_bin_collection/uk_bin_collection/councils/RushcliffeBoroughCouncil.py

90-90: datetime may be undefined, or defined from star imports

(F405)


94-94: date_format may be undefined, or defined from star imports

(F405)


97-97: datetime may be undefined, or defined from star imports

(F405)


101-101: date_format may be undefined, or defined from star imports

(F405)


106-106: datetime may be undefined, or defined from star imports

(F405)

🔇 Additional comments (1)
uk_bin_collection/uk_bin_collection/councils/RushcliffeBoroughCouncil.py (1)

84-87: Regex update correctly handles two dates and optional parenthetical bin labels

The new pattern looks appropriate for the examples (“grey”, “blue”, “garden waste”, “glass (purple lid)”), capturing two dates and normalising the type so that any parenthetical label (e.g. “(purple lid)”) is excluded from the captured bin type. This should keep bin types consistent while still matching the updated wording “collections will be … and …”.

@robbrad robbrad changed the base branch from master to dec_release December 7, 2025 11:18
@robbrad robbrad merged commit e64538a into robbrad:dec_release Dec 7, 2025
5 of 7 checks passed
@codecov
Copy link

codecov bot commented Dec 7, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.79%. Comparing base (37c8a80) to head (e0c484d).
⚠️ Report is 97 commits behind head on dec_release.

Additional details and impacted files
@@             Coverage Diff              @@
##           dec_release    #1756   +/-   ##
============================================
  Coverage        86.79%   86.79%           
============================================
  Files                9        9           
  Lines             1136     1136           
============================================
  Hits               986      986           
  Misses             150      150           

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

@coderabbitai coderabbitai bot mentioned this pull request Dec 7, 2025
@jimgolfgti jimgolfgti deleted the fix/rushcliffebc-scraping branch December 7, 2025 11:39
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.

2 participants