Merge pull request #634 from Hestia-Homes/eco-eligiblity-bug

handling edge case in search epc
This commit is contained in:
KhalimCK 2026-01-04 13:56:05 +08:00 committed by GitHub
commit 59c3c2c7a3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -551,7 +551,15 @@ class SearchEpc:
# Take the uprn from the most recent
uprns = {newest_epc["uprn"]}
else:
raise ValueError("Multiple UPRNs found - investigate me")
# We check if we have UPRNs that match the one we're given and if so, filter on those
if self.uprn is not None:
uprns = {u for u in uprns if int(u) == self.uprn}
if len(uprns) == 1:
logger.info(
f"Multiple UPRNs found but one matches provided UPRN {self.uprn}, using this UPRN"
)
else:
raise ValueError("Multiple UPRNs found - investigate me")
# if uprns:
# epc_uprn = uprns.pop()