mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-12 13:29:04 +00:00
A property without override or EPC falls back to the legacy column 🟩
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
faea3209b2
commit
ec7ba1f0d3
1 changed files with 10 additions and 5 deletions
|
|
@ -60,9 +60,7 @@ def resolve_filtered_property_ids(
|
|||
|
||||
if filters.property_types is not None:
|
||||
wanted = set(filters.property_types)
|
||||
types = _resolved_property_types(
|
||||
session, [row.id for row in candidates if row.id is not None]
|
||||
)
|
||||
types = _resolved_property_types(session, candidates)
|
||||
candidates = [
|
||||
row
|
||||
for row in candidates
|
||||
|
|
@ -88,10 +86,16 @@ _PROPERTY_TYPE_CODES: dict[str, str] = {
|
|||
|
||||
|
||||
def _resolved_property_types(
|
||||
session: Session, property_ids: list[int]
|
||||
session: Session, candidates: list[PropertyRow]
|
||||
) -> dict[int, str]:
|
||||
"""Each property's effective property_type per the ADR-0056 precedence:
|
||||
override (building_part 0) → lodged EPC."""
|
||||
override (building_part 0) → lodged EPC → predicted EPC → legacy column."""
|
||||
property_ids = [row.id for row in candidates if row.id is not None]
|
||||
by_legacy_column = {
|
||||
row.id: row.property_type
|
||||
for row in candidates
|
||||
if row.id is not None and row.property_type is not None
|
||||
}
|
||||
overrides = session.exec(
|
||||
select(PropertyOverrideRow)
|
||||
.where(col(PropertyOverrideRow.property_id).in_(property_ids))
|
||||
|
|
@ -119,6 +123,7 @@ def _resolved_property_types(
|
|||
by_override.get(pid)
|
||||
or by_epc_source["lodged"].get(pid)
|
||||
or by_epc_source["predicted"].get(pid)
|
||||
or by_legacy_column.get(pid)
|
||||
)
|
||||
if value is not None:
|
||||
resolved[pid] = value
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue