From 100949073f4324afd8f23e584cd3272a8d89ab95 Mon Sep 17 00:00:00 2001 From: Jun-te Kim Date: Thu, 2 Jul 2026 14:21:46 +0000 Subject: [PATCH] =?UTF-8?q?refetch=5Fsolar=3DFalse=20models=20with=20store?= =?UTF-8?q?d=20Solar=20insights=20and=20never=20calls=20Google=20?= =?UTF-8?q?=F0=9F=9F=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Fable 5 --- applications/modelling_e2e/handler.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/applications/modelling_e2e/handler.py b/applications/modelling_e2e/handler.py index b4848f694..bf9ca8b06 100644 --- a/applications/modelling_e2e/handler.py +++ b/applications/modelling_e2e/handler.py @@ -512,12 +512,11 @@ def handler( # held-open read Session. (The ``finally`` is the safety net.) scenario = ScenarioPostgresRepository(read_session).get_many([scenario_id])[0] products = catalogue_snapshot_with_off_catalogue_overrides(read_session) + # Stored Solar is read whatever refetch_solar says — the flag decides + # whether a UPRN with no stored row gets a live Google fetch, never + # whether solar is modelled at all. stored_solar: dict[int, Optional[dict[str, Any]]] = ( - {} - if not refetch_solar - else SolarPostgresRepository(read_session).get_many( - list(set(uprns.values())) - ) + SolarPostgresRepository(read_session).get_many(list(set(uprns.values()))) ) epc_repo = EpcPostgresRepository(read_session) stored_lodged_epcs: dict[int, EpcPropertyData] = ( @@ -615,15 +614,16 @@ def handler( landlord_overrides=overrides, ).effective_epc - solar_insights: Optional[dict[str, Any]] + # refetch_solar gates ONLY the paid Google call for UPRNs with no + # stored row; stored insights always feed the Modelling stage. + # (False here once meant "no solar at all" — the pre-rename + # `no_solar` semantics — which silently stripped solar from every + # plan in a re-model batch.) + solar_insights: Optional[dict[str, Any]] = stored_solar.get(uprn) solar_was_fetched = False - if not refetch_solar: - solar_insights = None - else: - solar_insights = stored_solar.get(uprn) - if solar_insights is None: - solar_insights = _solar_insights_for(solar_client, spatial) - solar_was_fetched = solar_insights is not None + if solar_insights is None and refetch_solar: + solar_insights = _solar_insights_for(solar_client, spatial) + solar_was_fetched = solar_insights is not None plan = run_modelling( effective_epc,