diff --git a/backend/app/db/models/materials.py b/backend/app/db/models/materials.py index f887fc25..97085d7a 100644 --- a/backend/app/db/models/materials.py +++ b/backend/app/db/models/materials.py @@ -18,6 +18,7 @@ class MaterialType(enum.Enum): exposed_floor_insulation = "exposed_floor_insulation" flat_roof_insulation = "flat_roof_insulation" room_roof_insulation = "room_roof_insulation" + windows_glazing = "windows_glazing" iwi_wall_demolition = "iwi_wall_demolition" iwi_vapour_barrier = "iwi_vapour_barrier" diff --git a/backend/app/plan/router.py b/backend/app/plan/router.py index 7a6df2da..f89395cc 100644 --- a/backend/app/plan/router.py +++ b/backend/app/plan/router.py @@ -61,6 +61,7 @@ async def trigger_plan(body: PlanTriggerRequest): logger.info("Getting the inputs") epc_client = EpcClient(auth_token=get_settings().EPC_AUTH_TOKEN) plan_input = read_csv_from_s3(bucket_name=get_settings().PLAN_TRIGGER_BUCKET, filepath=body.trigger_file_path) + uprn_filenames = read_dataframe_from_s3_parquet( bucket_name=get_settings().DATA_BUCKET, file_key="spatial/filename_meta.parquet" ) @@ -126,6 +127,10 @@ async def trigger_plan(body: PlanTriggerRequest): for p in input_properties: + # TODO: TEMP + if p.address1 == "The Hollies Farm House, Church Walk, Little Dalby": + continue + # Property recommendations p.get_components(cleaned) diff --git a/backend/app/plan/utils.py b/backend/app/plan/utils.py index 7aba99c9..4185c30e 100644 --- a/backend/app/plan/utils.py +++ b/backend/app/plan/utils.py @@ -175,11 +175,20 @@ def create_recommendation_scoring_data( scoring_dict["LOW_ENERGY_LIGHTING_ENDING"] = 100 scoring_dict["LIGHTING_ENERGY_EFF_STARTING"] = "Very Good" + if recommendation["type"] == "windows_glazing": + scoring_dict["MULTI_GLAZE_PROPORTION_ENDING"] = 100 + scoring_dict["WINDOWS_ENERGY_EFF_ENDING"] = "Average" + if scoring_dict["glazing_type_ENDING"] == "multiple": + pass + else: + raise NotImplementedError("Implement me") + if recommendation["type"] not in [ "mechanical_ventilation", "sealing_open_fireplace", "low_energy_lighting", "internal_wall_insulation", "external_wall_insulation", "cavity_wall_insulation", "loft_insulation", "room_roof_insulation", "flat_roof_insulation", - "solid_floor_insulation", "suspended_floor_insulation", "exposed_floor_insulation" + "solid_floor_insulation", "suspended_floor_insulation", "exposed_floor_insulation", + "windows_glazing" ]: raise NotImplementedError("Implement me") diff --git a/recommendations/Recommendations.py b/recommendations/Recommendations.py index 60cdb696..4b54cb52 100644 --- a/recommendations/Recommendations.py +++ b/recommendations/Recommendations.py @@ -6,6 +6,7 @@ from recommendations.RoofRecommendations import RoofRecommendations from recommendations.VentilationRecommendations import VentilationRecommendations from recommendations.FireplaceRecommendations import FireplaceRecommendations from recommendations.LightingRecommendations import LightingRecommendations +from recommendations.WindowsRecommendations import WindowsRecommendations from backend.ml_models.AnnualBillSavings import AnnualBillSavings @@ -35,6 +36,7 @@ class Recommendations: ) self.fireplace_recommender = FireplaceRecommendations(property_instance=property_instance) self.lighting_recommender = LightingRecommendations(property_instance=property_instance, materials=materials) + self.windows_recommender = WindowsRecommendations(property_instance=property_instance, materials=materials) def recommend(self): @@ -77,6 +79,11 @@ class Recommendations: if self.lighting_recommender.recommendation: property_recommendations.append(self.lighting_recommender.recommendation) + # Windows recommendations + self.windows_recommender.recommend() + if self.windows_recommender.recommendation: + property_recommendations.append(self.windows_recommender.recommendation) + # We insert temporary ids into the recommendations which is important for the optimiser later property_recommendations = self.insert_temp_recommendation_id(property_recommendations) diff --git a/recommendations/WindowsRecommendations.py b/recommendations/WindowsRecommendations.py index 572b27fa..6246fd95 100644 --- a/recommendations/WindowsRecommendations.py +++ b/recommendations/WindowsRecommendations.py @@ -56,7 +56,7 @@ class WindowsRecommendations: # We scale the number of windows based on the proportion of existing glazing if self.property.data["multi-glaze-proportion"] != "": - n_windows_scalar = 1 - (self.property.data["multi-glaze-proportion"] / 100) + n_windows_scalar = 1 - (int(self.property.data["multi-glaze-proportion"]) / 100) else: n_windows_scalar = self.COVERAGE_MAP.get(self.property.windows["glazing_coverage"], 1) @@ -86,7 +86,7 @@ class WindowsRecommendations: self.recommendation = [ { "parts": [], - "type": "window_glazing", + "type": "windows_glazing", "description": description, "starting_u_value": None, "new_u_value": None,