mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-27 23:35:01 +00:00
Two fixes so a multi-scenario export over a PasHub-fetched portfolio is correct: 1. Plan selection: take the NEWEST plan per (property, scenario), not the is_default one. is_default is one-per-property (not per-scenario), so it cannot scope a multi-scenario export — a property's default sits under a single scenario, leaving every other scenario with zero rows. _ROWS_SQL and _MEASURES_SQL now DISTINCT ON (property_id) ORDER BY created_at DESC, id DESC. 2. Effective-EPC descriptive block: match the header facts + current performance by UPRN (the latest epc_property for the source), because the PasHub re-fetch lands records with property_id = NULL — a property_id join silently fell back to a stale gov-EPC cert (wrong 2013-2025 lodgement dates / int property_type) or nothing. Lodgement date coalesces registration -> completion -> inspection (PasHub surveys carry only inspection_date). Descriptive prose elements stay on the property_id gov-EPC fallback (a survey lodges structured fields, not gov-EPC prose). Result on portfolio 838 / scenarios 1303+1304: both sheets populate 205 rows; property_type text on 204/205; lodgement dates 2026 on 200/205. Repository tests updated (uprn fixtures, newest-plan selection + a newest-wins case); 22 export tests pass, pyright clean. |
||
|---|---|---|
| .. | ||
| bulk_upload | ||
| comparable_properties | ||
| epc | ||
| fuel_rates | ||
| geospatial | ||
| historic_epc | ||
| hubspot_deals | ||
| landlord_overrides | ||
| magic_plan | ||
| materials | ||
| plan | ||
| product | ||
| property | ||
| property_baseline | ||
| scenario | ||
| scenario_export | ||
| solar | ||
| spatial | ||
| tasks | ||
| unstandardised_address | ||
| uploaded_file | ||
| __init__.py | ||
| postgres_unit_of_work.py | ||
| unit_of_work.py | ||