diff --git a/backend/app/plan/router.py b/backend/app/plan/router.py index 4064452f..ff56aa38 100644 --- a/backend/app/plan/router.py +++ b/backend/app/plan/router.py @@ -73,7 +73,8 @@ async def trigger_plan(body: PlanTriggerRequest): input_properties = [] for config in plan_input: # We validate each record in the file. If the record is NOT valid, we need to handle this accordingly - # TODO: implment validation + # TODO: implment validation. We should also standardise postcode and address in some fashion as + # a postcode of abcdef would be considered different to ABCDEF # Create a record in db property_id, is_new = create_property( session, portfolio_id=body.portfolio_id, address=config['address'], postcode=config['postcode'] @@ -310,7 +311,8 @@ async def trigger_plan(body: PlanTriggerRequest): # 3) the recommendations logger.info("Uploading recommendations to the database") - for i in range(0, len(input_properties), BATCH_SIZE): + session.commit() + for i in tqdm(range(0, len(input_properties), BATCH_SIZE)): try: # Take a slice of the input_properties list to make a batch batch_properties = input_properties[i:i + BATCH_SIZE] @@ -323,6 +325,11 @@ async def trigger_plan(body: PlanTriggerRequest): ) create_property_details_epc(session, property_details_epc) + # TODO: TEMP + if p.data["uprn"] == "": + print("Get rid of me!") + p.data["uprn"] = 0 + property_data = p.get_full_property_data() update_property_data( session, property_id=p.id, portfolio_id=body.portfolio_id, property_data=property_data diff --git a/datatypes/enums.py b/datatypes/enums.py index 1b0959e0..31f094ad 100644 --- a/datatypes/enums.py +++ b/datatypes/enums.py @@ -3,3 +3,4 @@ import enum class QuantityUnits(enum.Enum): m2 = "m2" + part = "part" diff --git a/recommendations/VentilationRecommendations.py b/recommendations/VentilationRecommendations.py index 35de9b3b..a639905b 100644 --- a/recommendations/VentilationRecommendations.py +++ b/recommendations/VentilationRecommendations.py @@ -54,7 +54,7 @@ class VentilationRecommendations(Definitions): part[0]["estimated_cost"] = estimated_cost part[0]["quantity"] = n_units - part[0]["quantity_unit"] = None + part[0]["quantity_unit"] = "part" # We recommend installing two mechanical ventilation systems self.recommendation = [