Commit graph

1820 commits

Author SHA1 Message Date
Daniel Roth
bd6af9b74f add a new main fuel value 2026-07-02 08:46:18 +00:00
Daniel Roth
543cb69414 3 more main_heating_system values 2026-07-02 08:44:25 +00:00
Daniel Roth
4a6a0aabba 5 new main_heating_system values 2026-07-02 08:43:43 +00:00
Khalim Conn-Kowlessar
4941e75683 fix(epc): follow energyMainsGas rename in new-approach resolver
The merge of main renamed epc_property.energyMainsGas ->
energyGasConnectionAvailable (migration 0252), but the new-approach
resolver read the old property name, which main never touched so it
survived the merge with no conflict and broke the build.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-01 15:56:16 +00:00
Khalim Conn-Kowlessar
59297c3495 Merge remote-tracking branch 'origin/main' into feature/update-ui-for-new-modelling 2026-07-01 15:34:29 +00:00
Daniel Roth
9b9a718b65
Merge pull request #342 from Hestia-Homes/main-heating-system-migration-2
New main heating system value
2026-07-01 15:45:45 +01:00
Daniel Roth
34d8301f24 migration files 2026-07-01 14:44:05 +00:00
Daniel Roth
d59aa7f079 new main heating system value 2026-07-01 14:43:39 +00:00
Daniel Roth
e63d80dd65
Merge pull request #341 from Hestia-Homes/water-heating-overrides-migration
Migration to add new water heating types
2026-07-01 15:23:38 +01:00
Daniel Roth
003913a90e migration files 2026-07-01 14:22:16 +00:00
Daniel Roth
ca781771f2 add new water heating types 2026-07-01 14:21:58 +00:00
Daniel Roth
ea4fee27d9
Merge pull request #340 from Hestia-Homes/rename-energy-column
Rename energyMainsGas to energyGasConnectionAvailable
2026-07-01 15:16:28 +01:00
Daniel Roth
eda1079e65 migration files 2026-07-01 14:08:01 +00:00
Daniel Roth
0a67aa5e4f rename energyMainsGas to energyGasConnectionAvailable 2026-07-01 14:07:26 +00:00
Daniel Roth
b2451651f5
Merge pull request #339 from Hestia-Homes/mixed-glazing-migration
Add Mixed glazing to GlazingValues
2026-07-01 13:38:18 +01:00
Daniel Roth
7a0d2a4d64 migration files 2026-07-01 12:09:14 +00:00
Daniel Roth
57d91cae1e Add Mixed glazing to GlazingValues 2026-07-01 12:08:57 +00:00
Daniel Roth
f5912070ee
Merge pull request #338 from Hestia-Homes/roof-type-migration
Roof type migration
2026-07-01 12:18:33 +01:00
Daniel Roth
6833bee645 migration files 2026-07-01 11:00:30 +00:00
Daniel Roth
c7ce0860c4 add flat room insulation values to RoofTypeValues 2026-07-01 10:59:53 +00:00
Daniel Roth
2ba084f858
Merge pull request #334 from Hestia-Homes/feature/dedupe-documents
Dedupe documents by only fetching the most recent for each S3 key
2026-07-01 09:27:18 +01:00
Daniel Roth
1969043cee
Merge pull request #336 from Hestia-Homes/not-null-lodged-on-baseline
Drop NotNull constraint on propertyBaselinePerformance lodged_ columns
2026-07-01 08:50:19 +01:00
Daniel Roth
782ad7b1d0 migration files 2026-07-01 07:42:14 +00:00
Daniel Roth
e36fb5398d lodged_ columns on property_baseline_performance are nullable 2026-07-01 07:41:55 +00:00
Daniel Roth
c9c1d37b1b
Merge pull request #335 from Hestia-Homes/main-heating-system-migration
Extend MainHeatingSystem PgEnum
2026-07-01 08:40:41 +01:00
Daniel Roth
813311f535 migration files 2026-07-01 07:24:19 +00:00
Daniel Roth
8789c9bab0 extend enum 2026-07-01 07:23:36 +00:00
Daniel Roth
54cf807f2b correct comment following previous commit 2026-06-30 11:10:19 +00:00
Daniel Roth
7c9faba215 sort dupe files based on upload timestamp rather than id 2026-06-30 11:06:58 +00:00
Daniel Roth
ac6983ae68 only get most recent version of each uploaded file per s3 key 2026-06-30 11:02:49 +00:00
KhalimCK
861bf144ae
Merge pull request #333 from Hestia-Homes/migration/material-active-index
Some checks failed
Test Suite / unit-tests (push) Has been cancelled
Add partial index on material(is_active) for the catalogue read
2026-06-29 14:16:22 +01:00
Jun-te Kim
f51fdca3d8 Add partial index on material(is_active) for the catalogue read
The modelling_e2e Lambda reads the active catalogue once per invocation
(SELECT * FROM material WHERE is_active ORDER BY id). Without an index this
was a full seq scan every time (~23ms), paid by all 32 concurrent Lambdas at
startup. Partial index on id WHERE is_active returns the active rows already
id-ordered — no sort, no filter.

Verified on dev: seq scan 23.2ms -> index scan 4.2ms.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-29 11:53:19 +00:00
Jun-te Kim
0321a0101e Merge branch 'main' of github.com:Hestia-Homes/assessment-model 2026-06-29 10:54:51 +00:00
Jun-te Kim
c7d951eb7a save 2026-06-29 10:54:48 +00:00
KhalimCK
4ae4487055
Merge pull request #331 from Hestia-Homes/feature/epc-calculator-read-fields-schema
feat(epc): persist 7 calculator-read fields dropped on save
2026-06-26 19:37:49 +01:00
Khalim Conn-Kowlessar
e4960db2c1 feat(epc): persist 7 calculator-read fields dropped on save
A recursive persistence-fidelity guard surfaced 7 fields the SAP calculator
reads but the epc_property projection had no column for, so they were silently
lost on save->reload (same bug class as the PV arrays / floor flags). All
additive, nullable except the PV-diverter bool; no backfill (defaults match
the domain defaults).

- epc_main_heating_detail: community_heating_boiler_fuel_type,
  community_heating_chp_fraction (community-heated CHP).
- epc_building_part: alt_wall_1_is_sheltered, alt_wall_2_is_sheltered, and
  wall_insulation_thermal_conductivity (jsonb to preserve Union[int,str]).
- epc_property: energy_pv_diverter_present (NOT NULL DEFAULT false),
  heating_cylinder_volume_measured_l, ventilation_air_permeability_ap50_m3_h_m2.

Includes generated migration 0246_minor_lady_bullseye.sql + snapshot/journal.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 18:34:45 +00:00
KhalimCK
138aca3ae8
Merge pull request #330 from Hestia-Homes/feature/epc-pv-and-floor-heatloss-schema
feat(epc): persist PV arrays and floor heat-loss flags
2026-06-26 17:41:26 +01:00
Khalim Conn-Kowlessar
a1548ca3a9 feat(epc): persist PV arrays and floor heat-loss flags
Add EPC persistence schema for two round-trip-fidelity gaps so the Model
backend can store the full EpcPropertyData faithfully:

- New child table epc_photovoltaic_array (one row per PV array), mirroring
  the epc_window child-table pattern.
- epc_floor_dimension: add is_exposed_floor and is_above_partially_heated_space
  boolean flags (NOT NULL DEFAULT false; additive, no backfill).

Includes generated migration 0245_magenta_nomad.sql + snapshot/journal.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 16:38:36 +00:00
Khalim Conn-Kowlessar
2f0f937fb6 fix(reporting): read scenario measures via denormalised recommendation.plan_id
The scenario measures modal came up empty because both measures routes
gated on EXISTS against plan_recommendations — a retired join table with
no rows for new-approach plans (25.7M legacy rows, none for e.g.
portfolio 812's plans), so the query returned zero measures.

Read the denormalised model instead: drive from the latest plan per
property (default or scenario) and JOIN recommendation by the indexed
property_id, scoped to the plan via recommendation.plan_id. Portfolio 812
default now returns 5 measures (solar_pv 54 homes/£266k, …) where it
returned 0. Also removes the stale commented query block that referenced
the retired plan_recommendations / recommendation_materials tables.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 11:42:19 +00:00
Khalim Conn-Kowlessar
eef9fdc171 fix(reporting): show scenario bars for EPC bands absent from the baseline
The breakdown chart looped only over baseline bands (epcBands), which the
query returns only for bands that have properties. So a band reached ONLY
after the scenario — e.g. A/B when no property starts that high — had no
row, and its scenario bar never rendered (portfolio 812: scenario yields
7 A + 2 B, baseline has none). Iterate a canonical A–G+Unknown order over
baseline ∪ scenario instead, so post-scenario-only bands still appear.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 11:25:45 +00:00
Jun-te Kim
e96c5ced16
Merge pull request #329 from Hestia-Homes/feature/show-uprn-remote-assessment
Show UPRN on selected address in remote assessment
2026-06-26 09:34:01 +01:00
Jun-te Kim
163412506c Show UPRN on selected address in remote assessment
Display the UPRN beneath the selected address on the remote assessment
page so it's available for quicker debugging. The value is already on
the selected address object from the postcode lookup; it just wasn't
rendered.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 14:50:36 +00:00
Jun-te Kim
165858b387
Merge pull request #328 from Hestia-Homes/feature/mark_for_deletion
feat(db): add property.marked_for_deletion migration
2026-06-25 15:04:28 +01:00
Jun-te Kim
752ffe1935 feat(db): add property.marked_for_deletion soft-delete flag
Add a NOT NULL DEFAULT false `marked_for_deletion` boolean to the
`property` table. Hard deletes are expensive (cascading child rows,
indexes), so a row is flagged here and a separate cron job performs the
physical delete later; reads can filter on the flag in the interim.

A constant default makes this a metadata-only ALTER on Postgres 11+ (no
table rewrite); existing rows backfill to false.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 12:18:32 +00:00
Khalim Conn-Kowlessar
7de48448c0 fix(reporting): temp guards for sub-baseline scenario post_sap
The modelling writes a target-level post_sap (e.g. ~C) even for homes
already above the scenario target, so plans can carry cost while modelling
post_sap BELOW the effective baseline. That skewed three reporting
surfaces. Three TEMP (demo) guards, all keyed on the effective baseline
(ADR-0002); revert once the Model team fixes the sub-baseline plans:

1. EPC band chart: post-scenario SAP clamped to GREATEST(baseline, post)
   so already-compliant properties aren't shown "improving" down a band
   (portfolio 796: EPC B 4,244 -> 1,660 wrongly, now 4,479).
2. n_units_upgraded + cost: exclude plans whose post_sap is below the
   effective baseline (not real upgrades) -- 796: 10,283 -> 9,765, -£1.28M.
3. total_sap_uplift / £-per-SAP: baseline is the effective SAP, not the
   null-for-new-approach current_sap_points, and counts genuine gains
   only -- uplift 0 -> 89,724, so £/SAP £0 -> £536.

Also fixes the no-plan branch to use the effective baseline instead of
the null current_sap_points (Unknown-band leakage).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 07:44:22 +00:00
Khalim Conn-Kowlessar
7bb2b093e5 perf(portfolio): only join EPC graph / plan LATERAL in count when a filter needs it
getPropertiesCount returns the portfolio's total property count for
pagination, but it dragged the whole read model through the COUNT: the
property_details_epc + property_baseline_performance + two epc_property
joins, plus a correlated default-plan LATERAL that ran once per property
(31k+ plan lookups for a large portfolio). None of those joins change a
COUNT (none multiply rows), so for an unfiltered load they were pure cost
— pushing the query to ~14.7s, past Vercel's 15s limit (intermittent
timeout on /api/properties).

Join only what an active filter references: no filters -> plain COUNT over
property; EPC/provenance filter -> add the epc-graph joins; Expected-EPC
filter -> add the plan LATERAL. Unfiltered count 14,667ms -> 93ms
(portfolio 796); provenance-filtered 156ms. getProperties is unchanged
(its LIMIT 1000 already bounds the LATERALs).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 18:51:54 +00:00
Daniel Roth
4b0133ac5c
Merge pull request #327 from Hestia-Homes/feature/wall-insulation-jsonb
SQL correction for wall insulation thickness column migration
2026-06-24 16:08:49 +01:00
Daniel Roth
1b7d314fdd SQL correction 2026-06-24 15:06:43 +00:00
Daniel Roth
198d9706d4
Merge pull request #326 from Hestia-Homes/feature/wall-insulation-jsonb
Make wall insulation thickness jsonb
2026-06-24 16:04:13 +01:00
Daniel Roth
e3a58e7e9c migration files 2026-06-24 15:02:21 +00:00