mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-12 13:29:04 +00:00
refetch_solar=False models with stored Solar insights and never calls Google 🟩
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
c1a558d2b5
commit
100949073f
1 changed files with 13 additions and 13 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue