From 8fcae893c758d123fedd91aba2cc51b088f7dee2 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Tue, 25 Jun 2024 17:14:57 +0100 Subject: [PATCH] set up uploader class for non-intrusives and built portfolio for non-intrusive VE --- .idea/Model.iml | 2 +- .idea/misc.xml | 2 +- backend/app/plan/router.py | 3 +- etl/customers/vander_elliot/non_intrusives.py | 39 +++++++++++++++++++ .../upload/UploadNonIntrusives.py | 1 - recommendations/Recommendations.py | 1 + 6 files changed, 44 insertions(+), 4 deletions(-) diff --git a/.idea/Model.iml b/.idea/Model.iml index b0f9c00d..4413bb06 100644 --- a/.idea/Model.iml +++ b/.idea/Model.iml @@ -7,7 +7,7 @@ - + diff --git a/.idea/misc.xml b/.idea/misc.xml index 1122b380..6f308057 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -3,7 +3,7 @@ - + diff --git a/backend/app/plan/router.py b/backend/app/plan/router.py index bfe5a9e4..5e10080e 100644 --- a/backend/app/plan/router.py +++ b/backend/app/plan/router.py @@ -355,7 +355,8 @@ async def trigger_plan(body: PlanTriggerRequest): p.get_components(cleaned, photo_supply_lookup, floor_area_decile_thresholds) p.get_spatial_data(uprn_filenames) # Call Google Solar API - solar_performance = solar_api_client.get(longitude=p.spatial["longitude"], latitude=p.spatial["latitude"]) + # TODO: Complete me + # solar_performance = solar_api_client.get(longitude=p.spatial["longitude"], latitude=p.spatial["latitude"]) logger.info("Getting components and epc recommendations") recommendations = {} diff --git a/etl/customers/vander_elliot/non_intrusives.py b/etl/customers/vander_elliot/non_intrusives.py index 57e0522b..7d092b5d 100644 --- a/etl/customers/vander_elliot/non_intrusives.py +++ b/etl/customers/vander_elliot/non_intrusives.py @@ -1,6 +1,11 @@ +import pandas as pd +from utils.s3 import save_csv_to_s3 from datetime import datetime from etl.non_intrusive_surveys.upload.UploadNonIntrusives import UploadNonIntrusives +PORTFOLIO_ID = 82 +USER_ID = 8 + def app(): """ @@ -72,3 +77,37 @@ def app(): uprn_lookup=uprn_lookup, survey_date=datetime.strptime('2024-06-21', '%Y-%m-%d') ) + non_intrusive.upload() + + # We can create the asset list from the uprn lookup + asset_list = [ + { + "uprn": x["uprn"], + "address": f"{x['House Number']} {x['Address Line 1']}", + "postcode": x["Postcode"] + } + for x in uprn_lookup + ] + + asset_list = pd.DataFrame(asset_list) + + # Store the asset list in s3 + filename = f"{USER_ID}/{PORTFOLIO_ID}/non_intrusives.csv" + save_csv_to_s3( + dataframe=asset_list, + bucket_name="retrofit-plan-inputs-dev", + file_name=filename + ) + + body = { + "portfolio_id": str(PORTFOLIO_ID), + "housing_type": "Private", + "goal": "Increase EPC", + "goal_value": "A", + "trigger_file_path": filename, + "already_installed_file_path": "", + "patches_file_path": "", + "non_invasive_recommendations_file_path": "", + "budget": None, + } + print(body) diff --git a/etl/non_intrusive_surveys/upload/UploadNonIntrusives.py b/etl/non_intrusive_surveys/upload/UploadNonIntrusives.py index 824f41f9..b711de8c 100644 --- a/etl/non_intrusive_surveys/upload/UploadNonIntrusives.py +++ b/etl/non_intrusive_surveys/upload/UploadNonIntrusives.py @@ -146,5 +146,4 @@ class UploadNonIntrusives: logger.info("Uploading non-intrusive notes to the database") session = sessionmaker(bind=db_engine)() - upload_non_intrusive_survey_notes(session=session, non_invasive_notes=non_invasive_notes, batch_size=500) diff --git a/recommendations/Recommendations.py b/recommendations/Recommendations.py index c9ac1072..827ca928 100644 --- a/recommendations/Recommendations.py +++ b/recommendations/Recommendations.py @@ -316,6 +316,7 @@ class Recommendations: expected_adjusted_energy = AnnualBillSavings.adjust_energy_to_metered( epc_energy_consumption=expected_heat_demand, current_epc_rating=property_instance.data["current-energy-rating"], + total_floor_area=property_instance.floor_area ) adjusted_heat_demand_change = (