From 7c5c7ceb0cdc989237d95be4f1dfa96ca7f4277f Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Sun, 28 Sep 2025 15:34:05 +0100 Subject: [PATCH] added better logging on dupes and adding new types to material table --- backend/Funding.py | 5 +++++ backend/app/db/models/materials.py | 2 ++ backend/engine/engine.py | 5 ++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/backend/Funding.py b/backend/Funding.py index 33c94e11..d590474c 100644 --- a/backend/Funding.py +++ b/backend/Funding.py @@ -578,6 +578,11 @@ class Funding: return pps.squeeze()["Cost Savings"] if measure_type == "flat_roof_insulation": + + # Not funding for properties starting at C or above + if self.starting_sap_band in ["Low_C", "High_C", "Low_B", "High_B", "Low_A", "High_A"]: + return 0 + pps = filtered_pps_matrix[filtered_pps_matrix["Measure_Type"] == "FRI"] if pps.shape[0] != 1: raise ValueError("Invalid FRI category") diff --git a/backend/app/db/models/materials.py b/backend/app/db/models/materials.py index 617ea0ac..347b66d5 100644 --- a/backend/app/db/models/materials.py +++ b/backend/app/db/models/materials.py @@ -45,6 +45,8 @@ class MaterialType(enum.Enum): scaffolding = "scaffolding" high_heat_retention_storage_heaters = "high_heat_retention_storage_heaters" sealing_fireplace = "sealing_fireplace" + roomstat_programmer_trvs = "roomstat_programmer_trvs" + time_temperature_zone_control = "time_temperature_zone_control" class DepthUnit(enum.Enum): diff --git a/backend/engine/engine.py b/backend/engine/engine.py index cc17222f..f4bffb17 100644 --- a/backend/engine/engine.py +++ b/backend/engine/engine.py @@ -534,7 +534,10 @@ async def model_engine(body: PlanTriggerRequest): if input_uprns: # Check for dupes if len(input_uprns) != len(set(input_uprns)): - raise ValueError("Duplicate UPRNs in the input data") + # Find the duplicate UPRNs + duplicates = set([x for x in input_uprns if input_uprns.count(x) > 1]) + # de-dupe input_uprns + raise ValueError(f"Duplicate UPRNs in the input data: {duplicates}") # If we have patches or overrides, we should read them in here patches, already_installed, non_invasive_recommendations, valuation_data = get_request_property_data(body)