diff --git a/backend/Property.py b/backend/Property.py index 7b5a6bc3..2d1dbd5d 100644 --- a/backend/Property.py +++ b/backend/Property.py @@ -61,7 +61,8 @@ class Property: n_bedrooms = None def __init__( - self, id, postcode, address, epc_record, already_installed=None, **kwargs + self, id, postcode, address, epc_record, already_installed=None, property_non_invasive_recommendations=None, + **kwargs ): self.epc_record = epc_record @@ -80,6 +81,10 @@ class Property: # cost and instead, provide a message that the measure has already been installed self.already_installed = ast.literal_eval(already_installed['already_installed']) if already_installed else [] + self.non_invasive_recommendations = ( + ast.literal_eval(property_non_invasive_recommendations['recommendations']) if + property_non_invasive_recommendations else [] + ) self.uprn = epc_record.get("uprn") self.full_sap_epc = epc_record.get("full_sap_epc") diff --git a/backend/app/plan/router.py b/backend/app/plan/router.py index 45d87dd3..e5a2aa79 100644 --- a/backend/app/plan/router.py +++ b/backend/app/plan/router.py @@ -242,6 +242,12 @@ async def trigger_plan(body: PlanTriggerRequest): bucket_name=get_settings().PLAN_TRIGGER_BUCKET, filepath=body.already_installed_file_path ) + non_invasive_recommendations = [] + if body.non_invasive_recommendations_file_path: + non_invasive_recommendations = read_csv_from_s3( + bucket_name=get_settings().PLAN_TRIGGER_BUCKET, filepath=body.non_invasive_recommendations_file_path + ) + cleaning_data = read_dataframe_from_s3_parquet( bucket_name=get_settings().DATA_BUCKET, file_key="sap_change_model/cleaning_dataset.parquet", ) @@ -297,6 +303,12 @@ async def trigger_plan(body: PlanTriggerRequest): x for x in already_installed if (x["address"] == config["address"]) and (x["postcode"] == config["postcode"]) ), {}) + + property_non_invasive_recommendations = next(( + x for x in non_invasive_recommendations if + (x["address"] == config["address"]) and (x["postcode"] == config["postcode"]) + ), {}) + input_properties.append( Property( id=property_id, @@ -304,6 +316,7 @@ async def trigger_plan(body: PlanTriggerRequest): postcode=epc_searcher.postcode_clean, epc_record=prepared_epc, already_installed=property_already_installed, + non_invasive_recommendations=property_non_invasive_recommendations, **Property.extract_kwargs(config) ) ) diff --git a/backend/app/plan/schemas.py b/backend/app/plan/schemas.py index 76eb49d2..59c0ebef 100644 --- a/backend/app/plan/schemas.py +++ b/backend/app/plan/schemas.py @@ -11,6 +11,7 @@ class PlanTriggerRequest(BaseModel): trigger_file_path: str already_installed_file_path: Optional[str] = None patches_file_path: Optional[str] = None + non_invasive_recommendations_file_path: Optional[str] = None exclusions: Optional[conlist(str, min_items=1)] = None # Pre-defined list of possibilities for exclusions diff --git a/etl/customers/immo/pilot/asset_list.py b/etl/customers/immo/pilot/asset_list.py index 614fa8a0..57fa5957 100644 --- a/etl/customers/immo/pilot/asset_list.py +++ b/etl/customers/immo/pilot/asset_list.py @@ -151,6 +151,7 @@ def app(): "trigger_file_path": filename, "already_installed_file_path": already_installed_filename, "patches_file_path": patches_filename, + "non_invasive_recommendations_file_path": non_invasive_recommendations_filename, "budget": None, } print(body)