handlging edge case in search epc

This commit is contained in:
Khalim Conn-Kowlessar 2026-01-04 13:55:15 +08:00
parent b1631bbf7a
commit 10b1ef4b2a

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()