Commit graph

63 commits

Author SHA1 Message Date
Daniel Roth
c96d964d24 feat(dates): restore a calendar picker behind DateInput
Dropping `<input type="date">` for the dd/mm/yyyy mask also dropped its
calendar, leaving typing as the only way to enter a date. ADR-0019 accepted
that cost but named the remedy: add a picker *behind* `DateInput`, writing the
same ISO value, rather than revert to the native control. That was felt
immediately in use, so this does it.

`DateInput` now renders a calendar button inside the field's right edge and a
Calendar in a Radix popover. Typing and picking are equal routes to the same
value — picking fills the text, typing moves the grid — so neither is
privileged and the two cannot disagree. The trigger is `type="button"` so it
cannot submit the form, and carries an aria-label, a bare icon having no
accessible name.

The calendar wrapper is written by hand rather than taken from the shadcn
registry: the published template targets react-day-picker v8/v9, whose
`classNames` keys differ from the `UI` enum v10 uses. It defaults to the enGB
locale, which carries `weekStartsOn: 1`, so the grid starts on Monday without
being told to.

The delicate part is the `Date` boundary. A calendar works in `Date`s, and
both obvious conversions are wrong: `new Date("2026-03-01")` is midnight UTC,
which is 29 February west of Greenwich, and `toISOString()` shifts the day back
the other way. So `isoToLocalDate` and `localDateToIso` build and read local
parts, and they are the only two functions in `src/utils/dates.ts` that touch
`Date` at all — everything else stays string-only. The round trip is tested
across a full month rather than at a sample day, because the failure only
appears on some days in some zones; the suite was also run under
TZ=America/Los_Angeles and TZ=Pacific/Auckland.

Dependencies: react-day-picker and date-fns, the latter already present
transitively and now direct at v4. `@tremor/react` bundles react-day-picker v8
nested and npm kept it isolated on date-fns v3, so nothing existing changed
version; no Tremor DatePicker is used anywhere in src, so there is no second
copy in the bundle. The alternative was a hand-rolled month grid with no
dependency, rejected because keyboard navigation and ARIA on a calendar are
easy to get subtly wrong and not worth owning.

ADR-0019's "the native calendar picker is gone" consequence was now false and
has been rewritten.

TESTS: tsc --noEmit and ESLint clean; vitest 582 passing (53 files), 24 of them
for the date helpers. NOT verified in a browser — this project has no jsdom or
testing-library, and `next build` was not run because it would statically
render pages against a DATABASE_URL still pointing at production. The new
Cypress case, which picks 17 March from the grid and expects 17/03/2026 in the
field, is unrun like the rest of that spec.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-22 15:39:11 +00:00
Khalim Conn-Kowlessar
9bf36ad4b6 perf(backfill): faster, resumable recommendation denormalization + ops tooling
Overhaul the recommendation plan_id/material_* backfill for the 21M-row prod
table (see docs/runbooks/recommendation-denormalization-backfill.md):

- Single combined pass: set plan_id + all four material_* columns in one write
  per row (was two full passes, rewriting every row twice). Guard + COALESCE keep
  it idempotent and resumable — done rows are never rewritten.
- Session tuning: synchronous_commit=off, tunable work_mem / maintenance_work_mem.
- Range + phase controls (BACKFILL_START_ID/END_ID/SKIP_CARDINALITY/ONLY_FINALIZE)
  to run disjoint id-range workers in parallel when the disk isn't the bottleneck.
- Percent-complete + ETA in the progress log.
- Finalize builds the two new indexes plain by default (faster in a quiet
  window) with a CONCURRENTLY toggle.

The real speed-up in prod was dropping the 3 secondary indexes for the backfill
then rebuilding — the table is packed (fillfactor 100) so updates can't go HOT
and otherwise maintain every index per row. Index drop/rebuild + vacuum are kept
as standalone SQL so ops controls exactly when the app loses/regains them:

- sql/drop-recommendation-backfill-indexes.sql
- sql/rebuild-recommendation-backfill-indexes.sql (1GB maintenance_work_mem — safe
  on the 4GB instance)
- sql/vacuum-recommendation.sql

run-sql.ts runs .sql files statement-by-statement, autocommitted (so VACUUM /
CREATE INDEX CONCURRENTLY work), for environments without the psql CLI. Wired up
as npm run db:run-sql and backfill:recommendation-restore.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-02 10:00:46 +00:00
Khalim Conn-Kowlessar
6f38677da3 Make recommendation denormalisation backfill safe and online
The 0222-0225 batch backfilled plan_id/material_* onto recommendation
inside drizzle's single migration transaction. On the production table
(~26M rows) that held an AccessExclusiveLock for hours, blocked unrelated
migrations, exhausted EBS throughput credits, and could not report
progress or resume.

Split schema DDL from data backfill:
- 0222/0224: keep only instant metadata-only DDL (ADD COLUMN + FK
  NOT VALID); drop the inline CREATE INDEX.
- 0223/0225: backfills removed (now no-ops pointing to the script).
- New src/app/db/backfill-recommendation-denormalization.ts: idempotent,
  resumable, batched (committed per batch) backfill that then builds the
  indexes CONCURRENTLY and validates the FKs online.
- CONTEXT.md: document recommendation->plan (1:1) and recommendation->
  material (now at most 1; legacy multi-material rows reconciled).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-08 08:36:39 +00:00
Daniel Roth
2011847aa7 new migration files 2026-06-03 12:55:49 +00:00
Khalim Conn-Kowlessar
62e9c548f1 Surface coordinator damp & mould commentary in the risk drill-down
The risk drill-down's coordinator-stage table showed "Yes" for every row,
which carried no useful signal. It also missed properties where the
coordinator wrote a comment without setting the growth flag.

Include rows where dampmould_growth is "yes" (case-insensitive) OR the
comment is populated, and render the comment in the cell — truncated
with a popover for the full text, or a "no note from coordinator"
placeholder when the row is here only because the flag was ticked.

Also drop the typo in the schema property name
(damnp -> damp); SQL column unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-28 14:58:23 +00:00
Khalim Conn-Kowlessar
486427f73d add vitest harness with parser and getRequiredDocs unit tests 2026-05-05 11:26:02 +00:00
Khalim Conn-Kowlessar
ff07111edd improving the solar ui and adding a map 2026-04-08 05:13:59 +00:00
Daniel Roth
cf821c9150 Add button and scenario selection / prioritisation 2026-02-27 17:04:56 +00:00
11dd4aeb51 fix s3 2026-01-19 13:14:07 +00:00
f4ea5e0e21 Fix invalid GitHub dependency for AWS S3 client 2026-01-19 13:10:49 +00:00
c3c0a01fd6 added delete button 2026-01-14 21:27:53 +00:00
54fa3e1ada merge with main 2025-12-08 15:34:03 +00:00
Khalim Conn-Kowlessar
3dcb0fef8d fixed params decoration 2025-12-08 15:25:51 +00:00
5c9d355689 next js 2025-12-08 12:20:07 +00:00
58c311f9f8 save new login screen 2025-12-08 10:03:40 +00:00
2aa56553d3 download photos works! 2025-11-07 22:47:49 +00:00
8016cc6f26 Merge branch 'main' into feature/abri_table 2025-10-31 12:53:17 +00:00
Khalim Conn-Kowlessar
ee253daf76 fixed slow loading of the properties data 2025-10-30 20:35:03 +00:00
8325cb6206 added files for reports 2025-10-30 17:15:30 +00:00
84413674c7 added fun confettit 2025-10-22 16:05:12 +00:00
5772f64f7a added migration scripts and ability to add a deal in hubspot@ 2025-10-22 15:44:00 +00:00
Khalim Conn-Kowlessar
73efe32801 magic link email tempalte live 2025-10-17 13:55:46 +00:00
Khalim Conn-Kowlessar
ef24c8f773 onboarding ui almost complete 2025-10-14 12:57:52 +00:00
Khalim Conn-Kowlessar
7d51fcc4dc working on sign in and onboarding 2025-10-13 08:52:34 +00:00
Khalim Conn-Kowlessar
65ce0ecb2a new decent homes ui 2025-09-23 20:43:08 +00:00
Khalim Conn-Kowlessar
45f5634f03 added fundamental layout for decent homes moniroting 2025-08-26 21:36:14 +00:00
Khalim Conn-Kowlessar
ce1a78005a added decent homes reporting 2025-08-24 18:04:25 +00:00
Khalim Conn-Kowlessar
c85d3956ce fixed merge 2025-08-21 16:07:32 +00:00
Jun-te kim
cf0cc5e79a added sqs utils 2025-08-19 13:10:49 +00:00
Khalim Conn-Kowlessar
70e4c7630e adding new materials attributes to product db 2025-08-15 16:46:37 +00:00
Khalim Conn-Kowlessar
85d6274e87 upgrading to next 15, react 18 2025-08-05 18:45:01 +00:00
Jun-te Kim
5f469ed5a9 save changes 2025-07-22 09:52:36 +00:00
Jun-te Kim
e90b1b31e9 dev container files and pakcage json upgraded 2025-07-22 08:54:18 +00:00
Khalim Conn-Kowlessar
be31116541 updating upload to allow excel and csv upload 2025-07-16 15:10:05 +01:00
Khalim Conn-Kowlessar
c199f05da9 adding speed insights to app 2025-07-15 19:12:13 +01:00
StefanWout
78d3716899 all kinds of weird attempts 2024-11-26 14:27:54 +00:00
StefanWout
f7800a910b form in modal for remote assesment in place 2024-11-18 17:10:25 +00:00
StefanWout
0cfef3e375 made all card images house icon 3 as it has brand colors, left other vector images in place for potential future use 2024-09-24 16:44:14 +01:00
Khalim Conn-Kowlessar
2f31432898 Added tremor dependencies 2024-04-15 18:51:16 +01:00
Khalim Conn-Kowlessar
3b259d7611 Added back to portfolio button with tooltip 2023-11-29 11:04:50 +00:00
Khalim Conn-Kowlessar
de3d727e39 Split out recommendationCostSummaryCard and added separator 2023-07-28 09:26:27 +01:00
Khalim Conn-Kowlessar
b4ea1ab69b Working on recommendations ui 2023-07-27 11:38:25 +01:00
Khalim Conn-Kowlessar
a1e9c075a0 properties table wip 2023-07-24 12:40:48 +01:00
Khalim Conn-Kowlessar
2775d732e7 Implemented initial version of presign url 2023-07-14 11:13:21 +01:00
Khalim Conn-Kowlessar
d1ae0c8470 Working on rough upload csv ui - added float menu for headless-ui 2023-07-13 10:56:28 +01:00
Khalim Conn-Kowlessar
a7e131119c Added in the template for csv upload 2023-07-12 18:58:07 +01:00
Khalim Conn-Kowlessar
40926b7106 Added layout of toolbar n portfolio page 2023-07-12 15:41:58 +01:00
Khalim Conn-Kowlessar
c022c813a0 Adding simple toolbar to porfolio page 2023-07-12 14:09:46 +01:00
Khalim Conn-Kowlessar
732cc8e688 getting cypress working - in progress 2023-07-11 11:18:46 +01:00
Khalim Conn-Kowlessar
bc742a8ecb setup cypress template 2023-07-11 11:00:27 +01:00