mirror of
https://github.com/Hestia-Homes/assessment-model.git
synced 2026-08-02 12:58:24 +00:00
fix(reporting): quote the camelCase aliases on the EPC coverage query
The card rendered a blank value and "NaN%": Postgres returns column names verbatim, so `AS without_epc` came back as `without_epc` while the code read `withoutEpc` — undefined, and `undefined / total * 100` is NaN. `db.execute<T>()` asserts the row shape rather than checking it, so tsc, lint and the full suite all passed on the broken query. The previous field names (`estimated`, `actual`) were single words and happened to survive the round trip; renaming to camelCase did not. Quoted aliases are the existing convention (see utils.ts). Verified against portfolio 839: keys come back as [withoutEpc, withEpc], and the card renders 29 / "0.5% have no EPC on record". Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
0933f05173
commit
5dc9c49132
1 changed files with 2 additions and 2 deletions
|
|
@ -147,8 +147,8 @@ export async function getEpcCoverageCounts(
|
|||
): Promise<EpcCoverageCounts> {
|
||||
const result = await db.execute<EpcCoverageCounts>(sql`
|
||||
SELECT
|
||||
SUM(CASE WHEN ${withoutEpcSql(sql`e`)} = true THEN 1 ELSE 0 END)::int AS without_epc,
|
||||
SUM(CASE WHEN ${withoutEpcSql(sql`e`)} = false THEN 1 ELSE 0 END)::int AS with_epc
|
||||
SUM(CASE WHEN ${withoutEpcSql(sql`e`)} = true THEN 1 ELSE 0 END)::int AS "withoutEpc",
|
||||
SUM(CASE WHEN ${withoutEpcSql(sql`e`)} = false THEN 1 ELSE 0 END)::int AS "withEpc"
|
||||
FROM property p
|
||||
LEFT JOIN property_details_epc e ON e.property_id = p.id
|
||||
${newApproachJoins}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue