diff --git a/backend/onboarders/base.py b/backend/onboarders/base.py index e69de29b..12ef9c94 100644 --- a/backend/onboarders/base.py +++ b/backend/onboarders/base.py @@ -0,0 +1,7 @@ +class OnboarderBase: + + def read(self): + pass + + def write(self): + pass diff --git a/backend/onboarders/parity.py b/backend/onboarders/parity.py index a77e76a8..a215d444 100644 --- a/backend/onboarders/parity.py +++ b/backend/onboarders/parity.py @@ -380,22 +380,27 @@ roof_mapping = { } -def classify_flat_roof(age_band: EpcConstructionAgeBand): - # # flat roof, which if there is observed insulation is just "flat, insulated", however there is a - # # different efficiency rating depending on insulation thickness - # # categories: - # # 12mm = very poor & has limited insulation description - # # 25, 50 = poor & has limited insulation description - # # 75, 100, 125mm = average (Flat, insulated) - # # 150, 175, 200, 225, 250mm = good (Flat, insulated) - # # 270mm+ = very good (Flat, insulated) - # # As built 2023 = Flat, insulated, Very good - # # 2003 - 2006, up to 2012-2022 = Flat insulated, Good - # # 1983-1990, 1996-2002 = Flat, insulated, Average - # # 1976-1982 = Flat, limited insulation, poor - # # 1967 - 1975 = Flat, limited insulation, Very Poor - # # 1950-1966 and earlier bands = flat, no insulation, very poor - raise NotImplementedError("Flat roof classification not implemented yet") +def classify_flat_roof(age_band: EpcConstructionAgeBand) -> EpcRoofDescriptions: + """ + For a flat, as built roof, these are the breakdowns: + + 2023 onwards → Flat, insulated + 2003–2022 → Flat, insulated + 1983–2002 → Flat, insulated + 1976–1982 → Flat, limited insulation + 1967–1975 → Flat, limited insulation + 1950–1966 and earlier → Flat, no insulation + """ + + year = age_band.start_year() + + if year >= 1983: + return EpcRoofDescriptions.flat_insulated + + if year >= 1967: + return EpcRoofDescriptions.flat_limited_insulation + + return EpcRoofDescriptions.flat_no_insulation def classify_pitched_loft_unknown(age_band: EpcConstructionAgeBand): @@ -421,7 +426,7 @@ AS_BUILT_ROOF_CLASSIFIERS = { def fill_roof_as_built(row): # Already resolved - if row.landlord_roof_description is not None: + if not pd.isnull(row.landlord_roof_description): return row.landlord_roof_description roof_type = row["Roof Construction"] @@ -435,7 +440,13 @@ def fill_roof_as_built(row): f"Missing age band for roof classification ({roof_type})" ) - return classifier(row.construction_age_band) + output = classifier(row.construction_age_band) + if output is None: + raise NotImplementedError( + f"Roof classification returned None for roof type '{roof_type}'" + ) + + return output data["landlord_roof_description"] = (