diff --git a/backend/Property.py b/backend/Property.py index 488d14d9..af568b86 100644 --- a/backend/Property.py +++ b/backend/Property.py @@ -51,6 +51,8 @@ class Property(BaseUtility): self.heat_loss_corridor = None self.mains_gas = None self.floor_height = None + self.insulation_wall_area = None + self.floor_area = None if epc_client: self.epc_client = epc_client @@ -241,6 +243,8 @@ class Property(BaseUtility): self.set_heat_loss_corridor() self.set_mains_gas() self.set_floor_height() + self.set_wall_area() + self.set_floor_area() for description, attribute in cleaned.items(): @@ -424,3 +428,22 @@ class Property(BaseUtility): } return property_details_epc + + def set_wall_area(self): + """ + This method is placeholder + It implements our floor area model to produce an estimate of the property's insulatable wall area + """ + + import random + self.insulation_wall_area = random.uniform(60, 100) + + def set_floor_area(self): + """ + Sets the floor area based on the EPC data + + """ + # We don't know the number of floors at the moment so we're going to assume 1 + # however this is something we'll need to use Verisk data for + + self.floor_area = float(self.data["total-floor-area"]) diff --git a/backend/app/db/functions/materials_functions.py b/backend/app/db/functions/materials_functions.py index 441d45a0..dd67bc4b 100644 --- a/backend/app/db/functions/materials_functions.py +++ b/backend/app/db/functions/materials_functions.py @@ -10,6 +10,6 @@ def get_materials(): """ Session = sessionmaker(bind=db_engine) with Session() as session: - materials = session.query(Material).all() + materials = session.query(Material).filter(Material.is_active).all() return materials if materials else [] diff --git a/backend/app/plan/router.py b/backend/app/plan/router.py index c885f333..eaa9a2ce 100644 --- a/backend/app/plan/router.py +++ b/backend/app/plan/router.py @@ -280,7 +280,8 @@ async def trigger_plan(body: PlanTriggerRequest): "default": True, "starting_u_value": rec.get("starting_u_value"), "new_u_value": rec.get("new_u_value"), - "sap_points": rec["sap_points"] # TODO: Add this to output + # TODO: Placeholder for SAP points in place + "sap_points": rec["sap_points"] # Remaining outputs yet to be handled } ) diff --git a/recommendations/FloorRecommendations.py b/recommendations/FloorRecommendations.py index d477e022..b45f6953 100644 --- a/recommendations/FloorRecommendations.py +++ b/recommendations/FloorRecommendations.py @@ -5,7 +5,7 @@ from backend.Property import Property from recommendations.rdsap_tables import default_wall_thickness, age_band_data from recommendations.recommendation_utils import ( r_value_per_mm_to_u_value, calculate_u_value_uplift, is_diminishing_returns, update_lowest_selected_u_value, - get_recommended_part, get_uvalue_estimate + get_recommended_part, get_uvalue_estimate, estimate_sap_points ) suspended_floor_insulation_parts = [ @@ -306,6 +306,7 @@ class FloorRecommendations(BaseUtility): "description": self._make_floor_description(part, depth), "starting_u_value": u_value, "new_u_value": new_u_value, + "sap_points": estimate_sap_points() } ) diff --git a/recommendations/WallRecommendations.py b/recommendations/WallRecommendations.py index bae17483..a9c590dc 100644 --- a/recommendations/WallRecommendations.py +++ b/recommendations/WallRecommendations.py @@ -5,7 +5,7 @@ from backend.Property import Property from model_data.BaseUtility import BaseUtility from recommendations.recommendation_utils import ( r_value_per_mm_to_u_value, calculate_u_value_uplift, is_diminishing_returns, update_lowest_selected_u_value, - get_recommended_part, get_uvalue_estimate + get_recommended_part, get_uvalue_estimate, estimate_sap_points ) external_wall_insulation_parts = [ @@ -338,6 +338,7 @@ class WallRecommendations(BaseUtility): "description": "Install " + self._make_description(part, depth), "starting_u_value": u_value, "new_u_value": new_u_value, + "sap_points": estimate_sap_points(), } ) @@ -400,6 +401,7 @@ class WallRecommendations(BaseUtility): ), "starting_u_value": u_value, "new_u_value": combined_new_u_value, + "sap_points": estimate_sap_points() } self.recommendations.append(recommendation) diff --git a/recommendations/recommendation_utils.py b/recommendations/recommendation_utils.py index ae906194..4ab7f6b6 100644 --- a/recommendations/recommendation_utils.py +++ b/recommendations/recommendation_utils.py @@ -3,6 +3,15 @@ from backend.Property import Property from statistics import mean +def estimate_sap_points(): + """ + This is a placeholder function. We will implement the proper version soon + :return: + """ + + return 999 + + def r_value_per_mm_to_u_value(depth_mm: int, r_value_per_mm: float): """ Converts R-value per mm to U-value in W/m²K.