mirror of
https://github.com/Hestia-Homes/assessment-model.git
synced 2026-07-22 08:48:34 +00:00
"Total carbon saved" on the reporting scenario overlay went negative (portfolio 796: -10,673 t/yr, £/tCO2 -8,195). Cause: the baseline side (getTotals → carbonSql) summed bp.lodged_co2_emissions_t_per_yr, which is NULL for predicted-only properties (12,064 of 796's 31,919 — no mirrored lodged estimate is written), so they contributed nothing to the baseline. The scenario side counted their plans' post_co2_emissions (21,046 t) in full, dragging saved below zero. The same subtraction fed £-per-tonne-CO2 and average-per-unit. carbonSql and energyConsumptionSql were left on lodged_* when ADR-0002 (effective performance is the canonical current, superseding "reporting stays on lodged") migrated the SAP fragments — the same reporting cards were already mixing effective SAP with lodged carbon. Move both to effective_*, which is populated for every property with a baseline row and is the figure the plans' post_* values were scored against. All call sites (reporting averages/totals, both scenario metrics routes, portfolio table CO2 column/filter) are current-state surfaces, so none wanted lodged. Legacy branch untouched. Verified live on 796: baseline and scenario totals computed in one snapshot with the shared fragment give saved = +4,059 t/yr (a plan regeneration was writing 796 mid-diagnosis, so values drift run-to-run; pre-fix the same snapshot maths gives ~ -13k and worsening as plans land). Legacy portfolio 433 totals unchanged. No regression-test seam exists for cross-query consistency (no DB test harness); consistency is structural — both sides compose the same carbonSql fragment. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| epcSources.test.ts | ||
| epcSources.ts | ||
| propertyDeletion.ts | ||
| provenance.test.ts | ||
| provenance.ts | ||