Merge pull request #438 from Hestia-Homes/feat/epc-building-part-lodged-fabric-overrides
Some checks failed
Test Suite / unit-tests (push) Has been cancelled

feat(db): persist rafter_insulation_thickness and wall_is_basement on epc_building_part
This commit is contained in:
KhalimCK 2026-07-22 09:26:10 +01:00 committed by GitHub
commit 391fb34463
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 13156 additions and 0 deletions

View file

@ -0,0 +1,2 @@
ALTER TABLE "epc_building_part" ADD COLUMN "rafter_insulation_thickness" jsonb;--> statement-breakpoint
ALTER TABLE "epc_building_part" ADD COLUMN "wall_is_basement" boolean;

File diff suppressed because it is too large Load diff

View file

@ -1919,6 +1919,13 @@
"when": 1784631274000,
"tag": "0274_seed_project_type_and_workstream",
"breakpoints": true
},
{
"idx": 275,
"version": "7",
"when": 1784656804281,
"tag": "0275_opposite_ronan",
"breakpoints": true
}
]
}

View file

@ -778,10 +778,28 @@ export const epcBuildingPart = pgTable(
roofConstruction: integer("roof_construction"),
roofInsulationLocation: jsonb("roof_insulation_location"),
roofInsulationThickness: jsonb("roof_insulation_thickness"),
// RdSAP 10 §5.11.2 — a roof insulated AT RAFTERS lodges its thickness here,
// NOT in roof_insulation_thickness (which stays null for rafter roofs).
// jsonb (not text) to match the sibling thickness columns: the value is
// Union[str, int] — "250mm" from the gov API, int mm from Site Notes.
rafterInsulationThickness: jsonb("rafter_insulation_thickness"),
roofConstructionType: text("roof_construction_type"),
curtainWallAge: text("curtain_wall_age"),
// RdSAP 10 §5.17 / Table 23 — selects the basement-wall U-value column for the
// part's primary wall. NOT a lodged U-value: it picks WHICH RdSAP default
// applies. Nullable is load-bearing — do NOT add .notNull().default(false).
// Three distinct states:
// null → "not stated" → fall back to the gov-API code-6 heuristic
// false → "explicitly system-built" → do NOT apply the heuristic
// true → basement wall
// RdSAP code 6 is canonically system-built, and the Elmhurst site-notes mapper
// sets false precisely to defeat the heuristic. Collapsing false to null INVERTS
// the result: a system-built wall bills as a basement wall, and via has_basement
// drags the whole ground floor onto the Table 23 basement-floor U-value.
wallIsBasement: boolean("wall_is_basement"),
// Room in roof (inlined)
roomInRoofFloorArea: real("room_in_roof_floor_area"),
roomInRoofConstructionAgeBand: text("room_in_roof_construction_age_band"),