From d2ce135f07f3b7fcda1f512b49b52c0e860c0de5 Mon Sep 17 00:00:00 2001 From: Daniel Roth Date: Mon, 26 Jan 2026 16:45:36 +0000 Subject: [PATCH] final missing mappings --- .../domain/mapping/lbwf/lbwf_element_map.py | 14 ++++-- .../domain/mapping/lbwf/lbwf_mapper.py | 50 ++++++++++--------- .../mapping/peabody/peabody_element_map.py | 12 +++-- backend/condition/processor.py | 2 +- 4 files changed, 44 insertions(+), 34 deletions(-) diff --git a/backend/condition/domain/mapping/lbwf/lbwf_element_map.py b/backend/condition/domain/mapping/lbwf/lbwf_element_map.py index 02722b11..8d6ea858 100644 --- a/backend/condition/domain/mapping/lbwf/lbwf_element_map.py +++ b/backend/condition/domain/mapping/lbwf/lbwf_element_map.py @@ -423,7 +423,7 @@ LBWF_ELEMENT_MAP: dict[str, ElementMapping] = { element=Element.HHSRS_ASBESTOS_AND_MMF, aspect_type=AspectType.RISK, ), - "HHSRSBIOCIDES": ElementMapping( + "HHSRSBIOC": ElementMapping( element=Element.HHSRS_BIOCIDES, aspect_type=AspectType.RISK, ), @@ -431,6 +431,14 @@ LBWF_ELEMENT_MAP: dict[str, ElementMapping] = { element=Element.HHSRS_CARBON_MONOXIDE, aspect_type=AspectType.RISK, ), + "HHSRSNO2": ElementMapping( + element=Element.HHSRS_CARBON_MONOXIDE, + aspect_type=AspectType.RISK, + ), # Duplicate of HHSRSCO; I think they relate to the same HHSRS hazard + "HHSRSSO2": ElementMapping( + element=Element.HHSRS_CARBON_MONOXIDE, + aspect_type=AspectType.RISK, + ), # Duplicate of HHSRSCO; I think they relate to the same HHSRS hazard "HHSRSLEAD": ElementMapping( element=Element.HHSRS_LEAD, aspect_type=AspectType.RISK, @@ -528,7 +536,3 @@ LBWF_ELEMENT_MAP: dict[str, ElementMapping] = { aspect_type=AspectType.RISK, ), } - -# Unhandled: -# DECNTHMINC -# EICINSFREQ diff --git a/backend/condition/domain/mapping/lbwf/lbwf_mapper.py b/backend/condition/domain/mapping/lbwf/lbwf_mapper.py index 635e5898..3d7b7349 100644 --- a/backend/condition/domain/mapping/lbwf/lbwf_mapper.py +++ b/backend/condition/domain/mapping/lbwf/lbwf_mapper.py @@ -27,32 +27,34 @@ class LbwfMapper(Mapper): uprn: int = client_data.uprn for raw_asset in client_data.assets: - try: - element_mapping: ElementMapping = LbwfMapper._map_element( - raw_asset.element_code - ) - except: - logger.warning( - f"Unrecognised LBWF Asset Element Code: {raw_asset.element_code}. Skipping record" - ) - continue + # Ignore metadata rows + if raw_asset.element_code not in ["EICINSFREQ", "DECNTHMINC"]: + try: + element_mapping: ElementMapping = LbwfMapper._map_element( + raw_asset.element_code + ) + except: + logger.warning( + f"Unrecognised LBWF Asset Element Code: {raw_asset.element_code}. Skipping record" + ) + continue - mapped_assets.append( - AssetCondition( - uprn=uprn, - element=element_mapping.element, - aspect_type=element_mapping.aspect_type, - value=raw_asset.attribute_code_description, - quantity=raw_asset.quantity, - install_date=raw_asset.install_date, - renewal_year=LbwfMapper._calculate_renewal_year( - raw_asset, survey_year - ), - element_instance=element_mapping.element_instance, - source_system=None, # Once we know the system name we'll set it here - comments=raw_asset.element_comments, + mapped_assets.append( + AssetCondition( + uprn=uprn, + element=element_mapping.element, + aspect_type=element_mapping.aspect_type, + value=raw_asset.attribute_code_description, + quantity=raw_asset.quantity, + install_date=raw_asset.install_date, + renewal_year=LbwfMapper._calculate_renewal_year( + raw_asset, survey_year + ), + element_instance=element_mapping.element_instance, + source_system=None, # Once we know the system name we'll set it here + comments=raw_asset.element_comments, + ) ) - ) return mapped_assets diff --git a/backend/condition/domain/mapping/peabody/peabody_element_map.py b/backend/condition/domain/mapping/peabody/peabody_element_map.py index 8fe2ccb9..2485136b 100644 --- a/backend/condition/domain/mapping/peabody/peabody_element_map.py +++ b/backend/condition/domain/mapping/peabody/peabody_element_map.py @@ -51,7 +51,7 @@ PEABODY_ELEMENT_MAP = { (53, 4): ElementMapping( element=Element.EXTERNAL_DECORATION, aspect_type=AspectType.PRESENCE ), - (53, 4): ElementMapping( + (53, 5): ElementMapping( element=Element.EXTERNAL_NOISE_INSULATION, aspect_type=AspectType.ADEQUACY ), (53, 14): ElementMapping( @@ -109,7 +109,7 @@ PEABODY_ELEMENT_MAP = { element=Element.GUTTERS, aspect_type=AspectType.MATERIAL, ), - (53, 18): ElementMapping( + (53, 21): ElementMapping( element=Element.PITCHED_ROOF_COVERING, aspect_type=AspectType.MATERIAL, ), @@ -334,8 +334,12 @@ PEABODY_ELEMENT_MAP = { element=Element.KITCHEN_SPACE_LAYOUT, aspect_type=AspectType.ADEQUACY, ), + (50, 14): ElementMapping( + element=Element.KITCHEN, + aspect_type=AspectType.TYPE, + ), (50, 17): ElementMapping( - element=Element.BATHRROM, + element=Element.BATHROOM, aspect_type=AspectType.LOCATION, ), (50, 18): ElementMapping( @@ -480,7 +484,7 @@ PEABODY_ELEMENT_MAP = { aspect_type=AspectType.FINISH, element_instance=2, ), - (51, 14): ElementMapping( + (51, 31): ElementMapping( element=Element.COMMUNAL_SPRINKLER, aspect_type=AspectType.PRESENCE, ), diff --git a/backend/condition/processor.py b/backend/condition/processor.py index a48e22f4..903c9f23 100644 --- a/backend/condition/processor.py +++ b/backend/condition/processor.py @@ -26,4 +26,4 @@ def process_file(file_stream: BinaryIO, source_key: str) -> None: for p in raw_properties: assets.extend(mapper.map_asset_conditions_for_property(p, survey_year)) - print(assets) # temp + print("done") # temp