diff --git a/backend/app/plan/router.py b/backend/app/plan/router.py index 3fbc2492..6367fe1c 100644 --- a/backend/app/plan/router.py +++ b/backend/app/plan/router.py @@ -325,12 +325,26 @@ def extract_propert_on_site_recommendations(config, already_installed, non_invas x for x in non_invasive_recommendations if (x["uprn"] == uprn) ), {}) + + # We patch the non-invasive recs that are ['cavity_extract_and_refill'] else: property_non_invasive_recommendations = next(( x for x in non_invasive_recommendations if (x["address"] == config["address"]) and (x["postcode"] == config["postcode"]) ), {}) + if isinstance(property_non_invasive_recommendations["recommendations"], str): + import ast + property_non_invasive_recommendations["recommendations"] = ast.literal_eval( + property_non_invasive_recommendations["recommendations"] + ) + transformed = [] + for rec in property_non_invasive_recommendations["recommendations"]: + if isinstance(rec, str): + transformed.append({"type": rec, }) + + property_non_invasive_recommendations["recommendations"] = str(transformed) + return property_already_installed, property_non_invasive_recommendations @@ -469,8 +483,8 @@ async def trigger_plan(body: PlanTriggerRequest): epcs_for_scoring = kwh_client.transform(data=kwh_client.prepare_epc(input_properties), cleaned=cleaned) - kwh_preds = model_api.predict_all( - df=epcs_for_scoring, + kwh_preds = model_api.paginated_predictions( + data=epcs_for_scoring, bucket=get_settings().DATA_BUCKET, model_prefixes=["heating_kwh_predictions", "hotwater_kwh_predictions"], extract_ids=False