Commit graph

1225 commits

Author SHA1 Message Date
Daniel Roth
10f7d4c188 migration 2026-06-15 08:59:46 +00:00
Daniel Roth
db0b3670f4 delete col 2026-06-15 08:59:24 +00:00
Daniel Roth
954fb5b16e migration 2026-06-15 08:52:41 +00:00
Daniel Roth
a3ee12a418 osmosis_survey_required column 2026-06-15 08:50:41 +00:00
Daniel Roth
3425dae3cc migration files 2026-06-10 14:25:37 +00:00
Daniel Roth
a5e07ffa1c add last_submission_date to hs deal table 2026-06-10 14:23:55 +00:00
Daniel Roth
2e9ec32c48 migration files 2026-06-09 13:57:31 +00:00
Daniel Roth
de963bbc39 add file type and file source 2026-06-09 13:56:52 +00:00
Jun-te Kim
d0d5ec0366
Merge pull request #310 from Hestia-Homes/feature/frontend_landlord_overrides
Feature/frontend landlord overrides
2026-06-08 16:23:21 +01:00
Jun-te Kim
c2b7e00075 new table for new deal proeprties we want 2026-06-08 14:42:50 +00:00
Jun-te Kim
cc134f8ce9
Merge branch 'main' into feature/frontend_landlord_overrides 2026-06-08 14:00:20 +01:00
Daniel Roth
7e2be3efbd Merge branch 'main' into feature/magicplan-ventilation-tables 2026-06-08 12:21:22 +00:00
Jun-te Kim
30d3e727d1 route of the address2uprn problem of float value 2026-06-08 09:38:48 +00:00
Jun-te Kim
f6545c2fa0 property override 2026-06-08 09:38:48 +00:00
Jun-te Kim
b9bbd916b5 Render finalising status on the bulk-upload page and auto-advance to complete
The async finaliser (ADR-0005) introduced the `finalising` status, but the
server page's STATUS_CONFIG had no entry for it, so it fell through to the
`ready_for_processing` fallback ("Awaiting column mapping") and never mounted the
live poller — the page looked stuck even though the Lambda had inserted the
properties and written `complete`.

- Add the `finalising` card ("Uploading to ARA") to STATUS_CONFIG.
- Render OnboardingProgress during `finalising` so it polls live.
- Refresh the server page once when the poll first sees a terminal status
  (guarded by a new `serverStatus` prop to avoid a loop; uses react-query v4
  onSuccess, no useEffect) so it advances to the "Processing complete" card.
- Add a `finalising` → "Uploading to ARA" badge on the uploads list.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-08 09:38:48 +00:00
Jun-te Kim
87aca96dfa bulk upload finaliser 2026-06-08 09:38:48 +00:00
Jun-te Kim
dff86b1ec2 save current progress 2026-06-08 09:38:48 +00:00
Jun-te Kim
22375e1746 Add Step 1 "Verify classification" to bulk-upload review (ADR-0004)
For uploads with classifier columns, surface the classifier's
description→enum assumptions on the awaiting_review screen so the user can
correct any (written source='user') and acknowledge before Finalise.
Previously only the multi-entry order step existed, so non-multi-entry
uploads got no classification review at all and the assumptions were
applied silently.

- detectMultiEntry: capture a sample whenever classifier columns are
  mapped (largest-count row if multi-entry, else first classified row);
  the sample now carries all classifier columns. "sample != null" means
  "there is something to verify"; largestCount >= 2 stays the multi-entry
  signal.
- setVerifyAck + verify-classification PATCH route + useConfirmVerification.
- VerifyClassificationPanel (Step 1); MultiEntryOrderingPanel slimmed to
  order-only with read-only classification annotation; canFinalize gated
  on both steps where each applies.
- Unit tests for detectMultiEntry + ordering helpers.

The verify_ack column + 0219 migration landed separately via #303.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-08 09:38:48 +00:00
Jun-te Kim
c9b7d71843 Show + edit sample classifications on awaiting_review (#298, #299)
#298: read the classifier's resolved enums for the multi-entry sample's
entries (joined from landlord_*_overrides by normalized description) and show
each beside the raw text, or "not classified" when absent.

#299: make each classification editable — a dropdown of the category's valid
enum values whose selection upserts the override by (portfolio, description)
with source='user', so the classifier never re-clobbers it. UI notes the
portfolio-wide blast radius. Verification ack is folded into the existing
order-confirm (no separate flag/migration); editing is optional review.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-08 09:38:48 +00:00
Jun-te Kim
65a5f57321 Confirm building-part ordering on awaiting_review (#297)
Adds the multiEntryOrdering jsonb column + interactive order picker: the
largest-count multi-entry sample is shown with a building-part dropdown per
file position (one Main building + Extensions), validated as a permutation.
A PATCH route persists { count: permutation } + confirmed, and Finalise is
disabled until the ordering is confirmed when the upload is multi-entry.

Migration for the new column is intentionally not included here — generated
after origin/main is merged (its multi_entry_summary migration lands first).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-08 09:38:48 +00:00
Jun-te Kim
9cb0cb19f3 lanlord exetension application 2026-06-08 09:38:21 +00:00
Jun-te Kim
052ab446e0 merged from main 2026-06-08 09:36:26 +00:00
Daniel Roth
b16e0f7d3d new tables for magicplan ventilation. move opening type from window table to window ventilation table 2026-06-08 09:25:16 +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
d2c9c0696a add guard clause when backfilling plan_id to recommendation 2026-06-05 10:13:49 +00:00
Daniel Roth
694bac47e1 backfill materials columns for recommendation table 2026-06-05 10:13:31 +00:00
Daniel Roth
62b10ef808 migration for materials columns on recommendation table 2026-06-05 10:03:34 +00:00
Daniel Roth
a2a5d7212a backfill plan_id using plan_recommendations 2026-06-05 08:16:27 +00:00
Daniel Roth
c40e64bdec add plan_id column to recommendation table 2026-06-05 08:12:57 +00:00
Jun-te Kim
fa9bf538da Add property_overrides table + override_component enum (0221)
The per-Property fact layer deferred by ADR-0004: one row per
(property, building_part, override_component) holding the resolved
landlord-override enum as a denormalised text snapshot, plus the raw
spreadsheet description it resolved from.

Schema only — no writer yet. The bulk_upload_finaliser application will
populate it (recalculate-on-rerun via upsert on the unique key). Design
and rationale (snapshot-not-FK, drop source, recalculate semantics) in
docs/design/bulk-upload-finaliser.md.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-04 09:52:37 +00:00
Daniel Roth
2011847aa7 new migration files 2026-06-03 12:55:49 +00:00
Daniel Roth
fb952a6716 update migration sql so that new jsonb fields are mapped correctly 2026-06-03 10:49:54 +00:00
Daniel Roth
9c918c29df migration files 2026-06-03 10:43:32 +00:00
Daniel Roth
5553fee32e Add EPC round-trip fidelity fixes and property_baseline_performance table to Drizzle schema 2026-06-03 10:42:13 +00:00
Daniel Roth
3430fa90f0 add "other" file type 2026-06-03 08:24:48 +00:00
Jun-te Kim
ca4946f594 Add verify_ack column to bulk_address_uploads (0219)
The "Verify classification" acknowledgement flag for ADR-0004 Step 1.
Gates Finalise whenever an upload has classifier columns, independent of
multi-entry, so it lives in its own column rather than on
multiEntryOrdering.

Plain additive column (boolean NOT NULL DEFAULT false), no data backfill,
so it applies cleanly with either `drizzle-kit migrate` or `push`. The
feature that reads/writes it lands separately on
feature/frontend_landlord_overrides.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-02 17:54:01 +00:00
Jun-te Kim
b84bcd848d Add multi_entry_ordering column to bulk_address_uploads
Additive nullable jsonb column for the user-confirmed building-part ordering
(ADR-0004, issue #297), generated off main. No data migration. The jsonb shape
type is co-located with the column so the schema is self-contained.

Split out as its own migration PR so the DB change can be approved and deployed
independently of the feature's app code.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-02 13:53:05 +00:00
Jun-te Kim
f67c7cfdd6 Add multi_entry_summary column to bulk_address_uploads
Additive nullable jsonb column for multi-entry building-part detection
(ADR-0004), generated off main. No data migration. The jsonb shape type is
co-located with the column so the schema is self-contained.

This is the only migration the multi-entry feature needs that isn't already
on main (the column_mapping inversion, sub_task.service, and the
landlord_overrides tables are all already merged). Split out so the DB change
can be approved and deployed independently of the feature's app code.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-02 12:43:50 +00:00
Jun-te Kim
546316eda9
Merge pull request #293 from Hestia-Homes/feature/non-booked-surveys
Some checks failed
Test Suite / unit-tests (push) Has been cancelled
Feature/non booked surveys
2026-05-29 13:37:30 +01:00
Khalim Conn-Kowlessar
f7b1402790 Swap coordinator/survey-date columns for outcome notes in Removed from Bookings
Removed properties have no coordinator or confirmed survey date by definition,
so those columns were always blank. Outcome notes are the field that actually
explains why the property dropped out of bookings.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-29 12:17:38 +00:00
Khalim Conn-Kowlessar
56fdfa06e4 Only let surveyed outcomes override a Do Not Book status
Previously, any HubSpot outcome would override bookingStatus="Do Not Book"
and keep the property in the normal pipeline. That was too permissive —
outcomes like "Tenant Refusal" or "Not Viable" combined with Do Not Book
should classify the property as Removed from Bookings, not lurk in Queries
or the survey-issues bucket.

Now only completed survey outcomes (Surveyed, Surveyed - Pending Upload,
EPC Completed) override Do Not Book. Any other outcome + Do Not Book
falls through to Removed from Bookings, surfaces in the Halted or Removed
panel, and gets the matching stage badge in the Properties tab. The
redundant "Removed from Bookings" chip in the drill-down table is gone
since the stage classification now carries that signal cleanly.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-29 12:05:53 +00:00
Jun-te Kim
c04ff901c1 Add landlord-override DB migrations (0215 data + 0216 schema)
Splits the DB migration artifacts off the frontend branch so they can
land independently:

- 0215_invert_column_mapping: one-shot data migration inverting
  bulk_address_uploads.column_mapping from header->field to field->header
  (drops 'skip' entries). One-shot — see file header and ADR-0003.
- 0216_add_subtask_service: adds sub_task.service (nullable text) to tag
  which pipeline a subtask belongs to (address2uprn vs
  landlord_description_overrides).

Includes the subtask.ts schema source for 0216 so drizzle's snapshot
stays consistent. No app code depends on these yet.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-05-29 09:50:03 +00:00
Khalim Conn-Kowlessar
5ff99a636b Add Surveyed Date and EPC Certificate Number as optional property columns
Both surface in the column-toggle dropdown and the CSV export, hidden by
default like the other optional columns. surveyedDate sits next to
designDate (chronological survey -> design order); epcPrn sits after the
lodgement date since the PRN is the output of lodgement.

epcPrn was already in the DB schema but absent from the HubspotDeal type
and mapper, so the plumbing is added alongside.

Extracts the CSV-formatting logic out of PropertyTable into a pure
propertyCsv module with tests, locking in the export contract (header
order, en-GB date formatting, null cells empty) so future column drift
is caught.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-28 20:29:10 +00:00
Khalim Conn-Kowlessar
9f552ad649 Reword "Excluded from Pipeline" card to "Halted or Removed"
Softer, less technical language for landlord-facing copy. The subtitle
now spells out the two states (halted before a survey, or removed from
the project entirely) so the relationship between the section header
and the two cards is explicit.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-28 18:03:45 +00:00
Khalim Conn-Kowlessar
2edfb11469 Surface "Removed from Bookings" and "Removed from Program" as distinct stages
Properties that are intentionally not progressing (bookingStatus = "Do Not
Book" with no outcome, or batch = "Removed from Program") were landing in
the "Queries" bucket, inflating it with non-actionable rows. Two new
terminal DisplayStage values now classify these explicitly, with
precedence Removed from Program > Removed from Bookings > Queries. Both
are excluded from pipeline funnel and stage-progress denominators
(sibling to Queries) and surface as their own cards under "Excluded from
Pipeline" on the analytics tab. Drill-down rows in Survey Issues get
slate chips when a deal carries either flag, preserving outcome history
for properties surveyed before being de-scoped.

Also removes the unused SurveyedResultsPieChart chain (component,
computeOutcomeSlices, OutcomeSlice, outcomePieSlices field).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-28 17:10:43 +00:00
Khalim Conn-Kowlessar
9e3df59ea0 Broaden the Awaab's Law panel to cover other condition issues
Coordinators record non-damp/mould observations (e.g. wasp nests) in the
same comments field, but the section was framed entirely around damp and
mould. Reframe the panel copy and table titles around "condition issues",
keep "Damp, Mould" up front so the Awaab's Law urgency still leads, and
mark the damp/mould rows specifically with a red badge column so they
don't blend into the broader list.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-28 15:33:08 +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
KhalimCK
ec10a53aeb
Merge pull request #287 from Hestia-Homes/bug/portfolio-invitations
Bug/portfolio invitations
2026-05-28 14:01:55 +01:00
Jun-te Kim
d37ce12f10 booking status 2026-05-28 12:01:22 +00:00
Khalim Conn-Kowlessar
7ced6c0818 Move inviteRequestSchema out of route.ts to satisfy Next 15 build
Next.js 15 enforces a strict allowlist of named exports from route.ts
files; "inviteRequestSchema" was rejected by the route-validator with
"is not a valid Route export field" during npm run build. Splitting the
schema into a sibling module (which is exempt from the allowlist) and
importing it from route.ts and the test. Renames the test file to
match its target module.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-28 11:29:54 +00:00