From dfe42a637414fa52c4a9e8a10bac977acd081a53 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Tue, 7 Jul 2026 11:38:47 +0000 Subject: [PATCH] =?UTF-8?q?Numeric=20RdSAP=20property-type=20codes=20map?= =?UTF-8?q?=20to=20their=20labels=20=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 --- backend/app/modelling/property_filters.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/backend/app/modelling/property_filters.py b/backend/app/modelling/property_filters.py index d7f715cdb..530a909cb 100644 --- a/backend/app/modelling/property_filters.py +++ b/backend/app/modelling/property_filters.py @@ -76,6 +76,17 @@ def resolve_filtered_property_ids( ] +# RdSAP numeric codes as lodged on some certs; text labels pass through as-is +# (ADR-0056 — the mapping is part of the shared preview contract). +_PROPERTY_TYPE_CODES: dict[str, str] = { + "0": "House", + "1": "Bungalow", + "2": "Flat", + "3": "Maisonette", + "4": "Park home", +} + + def _resolved_property_types( session: Session, property_ids: list[int] ) -> dict[int, str]: @@ -97,7 +108,10 @@ def _resolved_property_types( by_epc_source: dict[str, dict[int, str]] = {"lodged": {}, "predicted": {}} for epc in epcs: if epc.property_id is not None and epc.property_type is not None: - by_epc_source[epc.source][epc.property_id] = epc.property_type + value = epc.property_type + by_epc_source[epc.source][epc.property_id] = _PROPERTY_TYPE_CODES.get( + value, value + ) resolved: dict[int, str] = {} for pid in property_ids: