feat: add postcode lookup for wolverhampton city council#2069
feat: add postcode lookup for wolverhampton city council#2069InertiaUK wants to merge 2 commits into
Conversation
Users can provide either UPRN or postcode + house number. UPRN takes priority when provided (backward compatible). Uses Drupal AJAX form to resolve postcode to address list, matches by house number in the select options, then uses existing /find-my-nearest endpoint for bin data. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Warning Review limit reached
Your plan currently allows 2 reviews/hour. Refill in 24 minutes and 10 seconds. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more review capacity refills, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than trial, open-source, and free plans. In all cases, review capacity refills continuously over time. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughWolverhampton Council integration is updated to enable UPRN resolution from postcode and optional house number, eliminating the prior manual lookup requirement. Test configuration, new AJAX helpers, and parse_data refactoring implement the updated flow with defensive HTML parsing. ChangesWolverhampton UPRN Resolution via Postcode
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2069 +/- ##
=======================================
Coverage 86.67% 86.67%
=======================================
Files 9 9
Lines 1141 1141
=======================================
Hits 989 989
Misses 152 152 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
uk_bin_collection/uk_bin_collection/councils/WolverhamptonCityCouncil.py (1)
109-116: 💤 Low valueAdd defensive check for date format parsing.
The
split(": ")[1]on line 116 assumes the h4 text follows the exact format"Next date: DATE". If the council changes the separator (e.g., to a hyphen), this will raise anIndexErrorwithout context.🛡️ Optional: Add format validation
service_name = h3.text.strip() - next_date = next_date_h4.text.split(": ")[1] + date_text = next_date_h4.text + if ": " not in date_text: + raise ValueError(f"Unexpected date format: {date_text}") + next_date = date_text.split(": ")[1]🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@uk_bin_collection/uk_bin_collection/councils/WolverhamptonCityCouncil.py` around lines 109 - 116, The parsing assumes next_date_h4.text contains "Next date: DATE" and does next_date = next_date_h4.text.split(": ")[1]; change this to a defensive parse in the block that handles bin_div / next_date_h4 (refer to variables next_date_h4, service_name, next_date) by checking the split result length or using str.partition or a regex to extract the portion after the separator, and if the separator is missing fallback to either None, an empty string, or skip this bin_div while emitting a clear debug/warning log mentioning service_name and the unexpected next_date_h4.text so the code won't raise IndexError on malformed formats.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@uk_bin_collection/uk_bin_collection/councils/WolverhamptonCityCouncil.py`:
- Line 82: The code reads kwargs.get("paon") into user_paon but tests provide
"house_number", causing _resolve_uprn_from_postcode() to receive None and return
the wrong address; update the retrieval to use kwargs.get("house_number") (or
map house_number -> paon) so user_paon contains the house number before calling
_resolve_uprn_from_postcode(), ensuring the resolver is passed the correct paon
value; verify in the function that user_paon is forwarded to
_resolve_uprn_from_postcode() and adjust any variable names if needed.
---
Nitpick comments:
In `@uk_bin_collection/uk_bin_collection/councils/WolverhamptonCityCouncil.py`:
- Around line 109-116: The parsing assumes next_date_h4.text contains "Next
date: DATE" and does next_date = next_date_h4.text.split(": ")[1]; change this
to a defensive parse in the block that handles bin_div / next_date_h4 (refer to
variables next_date_h4, service_name, next_date) by checking the split result
length or using str.partition or a regex to extract the portion after the
separator, and if the separator is missing fallback to either None, an empty
string, or skip this bin_div while emitting a clear debug/warning log mentioning
service_name and the unexpected next_date_h4.text so the code won't raise
IndexError on malformed formats.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 83218e51-f463-4e63-b144-e38d0c895465
📒 Files selected for processing (2)
uk_bin_collection/tests/input.jsonuk_bin_collection/uk_bin_collection/councils/WolverhamptonCityCouncil.py
Summary
Testing
WV3 9NZ+ UPRN100071205205✅WV3 9NZ+ paon32✅Summary by CodeRabbit
New Features
Bug Fixes