From 02b76cd9fe6e24a30808352e6642799f11bbaacd Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Fri, 24 Nov 2023 11:01:44 +0000 Subject: [PATCH] Updating recommendation engine for new cost data --- backend/app/db/functions/recommendations_functions.py | 6 +++--- backend/app/plan/router.py | 1 - recommendations/VentilationRecommendations.py | 2 +- recommendations/optimiser/optimiser_functions.py | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/backend/app/db/functions/recommendations_functions.py b/backend/app/db/functions/recommendations_functions.py index 0bdf69ce..5d468db9 100644 --- a/backend/app/db/functions/recommendations_functions.py +++ b/backend/app/db/functions/recommendations_functions.py @@ -75,7 +75,7 @@ def upload_recommendations(session: Session, recommendations_to_upload, property "property_id": property_id, "type": rec["type"], "description": rec["description"], - "estimated_cost": rec["cost"], + "estimated_cost": rec["total"], "default": rec["default"], "starting_u_value": rec.get("starting_u_value"), "new_u_value": rec.get("new_u_value"), @@ -102,10 +102,10 @@ def upload_recommendations(session: Session, recommendations_to_upload, property { "recommendation_id": recommendation_id, "material_id": part["id"], - "depth": part["depths"][0] if part["depths"] else None, + "depth": int(part["depth"]) if part["depth"] else None, "quantity": part["quantity"], "quantity_unit": part["quantity_unit"], - "estimated_cost": part["estimated_cost"], + "estimated_cost": part["total"], } for rec, recommendation_id in zip(recommendations_to_upload, uploaded_recommendation_ids) for part in rec["parts"] diff --git a/backend/app/plan/router.py b/backend/app/plan/router.py index fffc604e..37f673b4 100644 --- a/backend/app/plan/router.py +++ b/backend/app/plan/router.py @@ -318,7 +318,6 @@ async def trigger_plan(body: PlanTriggerRequest): batch_properties = input_properties[i:i + BATCH_SIZE] for p in batch_properties: - # Your existing operations property_details_epc = p.get_property_details_epc( portfolio_id=body.portfolio_id, rating_lookup=rating_lookup diff --git a/recommendations/VentilationRecommendations.py b/recommendations/VentilationRecommendations.py index a0b188f7..c330104f 100644 --- a/recommendations/VentilationRecommendations.py +++ b/recommendations/VentilationRecommendations.py @@ -52,7 +52,7 @@ class VentilationRecommendations(Definitions): estimated_cost = n_units * part[0]["cost"] - part[0]["estimated_cost"] = estimated_cost + part[0]["total"] = estimated_cost part[0]["quantity"] = n_units part[0]["quantity_unit"] = "part" diff --git a/recommendations/optimiser/optimiser_functions.py b/recommendations/optimiser/optimiser_functions.py index 869880cf..03aa38bd 100644 --- a/recommendations/optimiser/optimiser_functions.py +++ b/recommendations/optimiser/optimiser_functions.py @@ -22,7 +22,7 @@ def prepare_input_measures(property_recommendations, goal): [ { "id": rec["recommendation_id"], - "cost": rec["cost"], + "cost": rec["total"], "gain": rec[goal_key], "type": rec["type"] }