diff --git a/backend/app/plan/router.py b/backend/app/plan/router.py index 42014bb3..a35f36ec 100644 --- a/backend/app/plan/router.py +++ b/backend/app/plan/router.py @@ -492,38 +492,38 @@ async def trigger_plan(body: PlanTriggerRequest): for p in batch_properties: # Your existing operations - property_details_epc = p.get_property_details_epc( - portfolio_id=body.portfolio_id, rating_lookup=rating_lookup - ) - create_property_details_epc(session, property_details_epc) - - update_or_create_property_spatial_details(session, p.uprn, p.spatial) - - # 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 - ) - + # property_details_epc = p.get_property_details_epc( + # portfolio_id=body.portfolio_id, rating_lookup=rating_lookup + # ) + # create_property_details_epc(session, property_details_epc) + # + # update_or_create_property_spatial_details(session, p.uprn, p.spatial) + # + # # 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 + # ) + # recommendations_to_upload = recommendations.get(p.id, []) - if not recommendations_to_upload: - continue - - new_plan_id = create_plan(session, { - "portfolio_id": body.portfolio_id, - "property_id": p.id, - "is_default": True - }) - - uploaded_recommendation_ids = upload_recommendations(session, recommendations_to_upload, p.id) - - create_plan_recommendations( - session, plan_id=new_plan_id, recommendation_ids=uploaded_recommendation_ids - ) + # if not recommendations_to_upload: + # continue + # + # new_plan_id = create_plan(session, { + # "portfolio_id": body.portfolio_id, + # "property_id": p.id, + # "is_default": True + # }) + # + # uploaded_recommendation_ids = upload_recommendations(session, recommendations_to_upload, p.id) + # + # create_plan_recommendations( + # session, plan_id=new_plan_id, recommendation_ids=uploaded_recommendation_ids + # ) # Get defaults default_recommendations = [r for r in recommendations_to_upload if r["default"]] @@ -531,8 +531,10 @@ async def trigger_plan(body: PlanTriggerRequest): new_sap_points = float(p.data["current-energy-efficiency"]) + total_sap_points new_epc = sap_to_epc(new_sap_points) + valuations = PropertyValuation.estimate(property_instance=p, target_epc=new_epc) + property_valuation_increases.append( - PropertyValuation.estimate(property_instance=p, target_epc=new_epc) + valuations["average_increased_value"] - valuations["current_value"] ) # Commit the session after each batch