diff --git a/backend/Property.py b/backend/Property.py index c54405b2..72d1d169 100644 --- a/backend/Property.py +++ b/backend/Property.py @@ -60,6 +60,7 @@ class Property: # Surplus information, that can be provided as optional inputs, by a customer n_bathrooms = None n_bedrooms = None + building_id = None # Used to group properties together into a single building def __init__( self, @@ -193,12 +194,14 @@ class Property: return { "n_bathrooms": n_bathrooms, "n_bedrooms": n_bedrooms, + "building_id": kwargs.get("building_id", None), } def parse_kwargs(self, kwargs): # We extract the elements from kwargs that we recognise. Anything additional is ignored self.n_bathrooms = kwargs.get("n_bathrooms", None) self.n_bedrooms = kwargs.get("n_bedrooms", None) + self.building_id = kwargs.get("building_id", None) def create_base_difference_epc_record(self, cleaned_lookup: dict): """ diff --git a/backend/app/plan/router.py b/backend/app/plan/router.py index 0cf670c2..2832989e 100644 --- a/backend/app/plan/router.py +++ b/backend/app/plan/router.py @@ -263,7 +263,6 @@ async def trigger_plan(body: PlanTriggerRequest): bucket_name=get_settings().DATA_BUCKET, file_key="sap_change_model/cleaning_dataset.parquet", ) - # TODO: insert building id input_properties = [] for config in tqdm(plan_input): # We validate each record in the file. If the record is NOT valid, we need to handle this accordingly @@ -366,9 +365,22 @@ async def trigger_plan(body: PlanTriggerRequest): for p in input_properties: p.get_components(cleaned, photo_supply_lookup, floor_area_decile_thresholds, energy_consumption_client) p.get_spatial_data(uprn_filenames) - # Call Google Solar API - # TODO: Complete me - solar_performance = solar_api_client.get(longitude=p.spatial["longitude"], latitude=p.spatial["latitude"]) + + building_ids = [ + { + "building_id": p.building_id, "longitude": p.spatial["longitude"], "latitude": p.spatial["latitude"] + } for p in input_properties if p.building_id is not None + ] + if building_ids: + # Model the solar potential at the building level + print("complete me") + else: + # Model the solar potential at the property level + for p in input_properties: + # 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 = {}