From db7eb69dd10621843f8ae3b693005882432c33d3 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Tue, 5 Dec 2023 13:30:45 +0000 Subject: [PATCH] handle bug where neigther ewi or iwi are selected as options via optimisation --- backend/app/plan/router.py | 11 +++++++++++ backend/ml_models/Valuation.py | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/backend/app/plan/router.py b/backend/app/plan/router.py index adc9eac1..6954d89f 100644 --- a/backend/app/plan/router.py +++ b/backend/app/plan/router.py @@ -298,6 +298,17 @@ async def trigger_plan(body: PlanTriggerRequest): t for t in missing_types if t not in ["internal_wall_insulation", "external_wall_insulation"] ] + # We check if NO wall insulation was selected but iwi and ewi are available + # This condition will check + # 1) iwi and ewi are both in missing_types + # 2) iwi and ewi are not in default_types + # If both of these are true, it means that no wall insulation was selected via the optimisation routine + # but both are possible, so we need to select a default. We default to iwi because it's usually cheaper + if (("internal_wall_insulation" in missing_types) and ("external_wall_insulation" in missing_types)) and ( + ("internal_wall_insulation" not in default_types) and ("external_wall_insulation" not in default_types) + ): + missing_types = [t for t in missing_types if t != "external_wall_insulation"] + if missing_types: for missed_type in missing_types: missed = [r for r in property_recommendations if r["type"] == missed_type] diff --git a/backend/ml_models/Valuation.py b/backend/ml_models/Valuation.py index 51925b22..9e409b9f 100644 --- a/backend/ml_models/Valuation.py +++ b/backend/ml_models/Valuation.py @@ -15,6 +15,10 @@ class PropertyValuation: 100071264896: 128000, # Based on next door neighbour: https://themovemarket.com/tools/propertyprices/flat-2-queens-wood-house-219 # -brandwood-road-birmingham-b14-6pu + 100070533688: 218000, # Based on Zoopla's estimation of 95 Tenby Road, which is also end terrace + 100070505235: 344000, # Based on Zoopla's estimation of 131 School road, which is also semi-detached + 100070513306: 182000, # Based on Zoopla's estimation of 61 Simmons Drive + 100071306896: 77000, # Based on Flat 2 of 44 Wedgewood Road on Zoopla } # We base our valuation uplifts on a number of sources