Handled windows edge case

This commit is contained in:
Khalim Conn-Kowlessar 2025-12-08 22:35:21 +00:00
parent c320c2d565
commit 0b026c0c4c
2 changed files with 26 additions and 1 deletions

View file

@ -405,6 +405,29 @@ def check_duplicate_uprns(plan_input):
return True
def check_duplicate_property_ids(input_properties):
"""
Simple function to check if the input data contains duplicated property IDs. This will happen in very rare
cases where we have properties across different servers, where the input UPRN is possibly incorrect and we
find the right property via an address search, instead of a UPRN search and so we end up with the same property
twice.
:param input_properties:
:return:
"""
input_property_ids = [x.id for x in input_properties]
if input_property_ids:
# Check for dupes
if len(input_property_ids) != len(set(input_property_ids)):
# Find the duplicate property IDs
duplicates = set([x for x in input_property_ids if input_property_ids.count(x) > 1])
# de-dupe input_uprns
raise ValueError(f"Duplicate property IDs in the input data: {duplicates}")
return True
def averages_cleaning(prepared_epc: EPCRecord, cleaning_data: pd.DataFrame):
"""
Placeholder cleaning function to handle edge cases where we have missing data for
@ -780,6 +803,8 @@ async def model_engine(body: PlanTriggerRequest):
if not input_properties:
return Response(status_code=204)
check_duplicate_property_ids(input_properties)
# We check if we have inspections data and store it in the database if so. We'll update or create
# aginst each property if
if inspections_map:

View file

@ -190,7 +190,7 @@ class WindowsRecommendations:
raise ValueError("Invalid glazing type - implement me")
if self.property.data["windows-energy-eff"] == "Very Good":
raise ValueError("Very Good energy efficiency is not supported")
windows_energy_eff = "Very Good"
# For post 2002 windows, the energy efficiency is "Good" and so for the simulation, we simulate with "Good"