Skip to content

fix: look up lambeth uprn from postcode and house number - #2321

Open
InertiaUK wants to merge 1 commit into
robbrad:masterfrom
InertiaUK:fix/lambeth-postcode-lookup
Open

InertiaUK wants to merge 1 commit into
robbrad:masterfrom
InertiaUK:fix/lambeth-postcode-lookup

Conversation

@InertiaUK

@InertiaUK InertiaUK commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Lambeth needed a UPRN. The same waste service the scraper already calls has an LLPG address search (POST wasteservice.lambeth.gov.uk/LLPG/addressSearch with {"postcode": ...}) that returns structured PAO/SAO fields and the UPRN, so the scraper now uses it when no UPRN is given.

  • Postcode + house number is enough on its own; UPRN still takes priority when passed
  • Whole properties are sorted ahead of flats and units that share the same number, so a house number lands on the property itself when the LLPG has one
  • House number matched as a whole token ("5" won't match "15"); a number not in the postcode raises ValueError
  • Added timeout=30 to the services request
  • input.json gains postcode / house_number matching the existing test UPRN

Testing

  • Postcode + house number: SW4 6BS + 5 resolves to 100021881738 (same as the existing test UPRN), 3 collections returned
  • UPRN only (backward compat): 100021881738, 3 collections returned
  • SW4 6BS + 128 (no such house) raises ValueError: No address matching '128'
  • Run end to end through my own API as well

Uses the waste service's own LLPG address search to find the UPRN when
only a postcode and house number are given. Whole properties are
preferred over flats at the same number. A UPRN is still used when
passed. Adds a timeout to the services request.
@coderabbitai

coderabbitai Bot commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 58 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9c429e04-098d-4d25-8913-0386959b3dff
Commits

Reviewing files that changed from the base of the PR and between 0d1b26a and 5d3fc5d.

Files selected for processing: 2
  • uk_bin_collection/tests/input.json
  • uk_bin_collection/uk_bin_collection/councils/LondonBoroughLambeth.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@codecov

codecov Bot commented Oct 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.57%. Comparing base (0d1b26a) to head (5d3fc5d).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2321   +/-   ##
=======================================
  Coverage   83.57%   83.57%           
=======================================
  Files          43       43           
  Lines        3380     3380           
=======================================
  Hits         2825     2825           
  Misses        555      555           

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

This branch has not been deployed

No deployments
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