Person page: server-side search; stop loading the whole tree #247
Reference in New Issue
Block a user
Delete Branch "person-page-server-search"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Follow-up to the N+1 fix. The person page fetched the entire tree on every open — all persons (name map + relative pickers) and all events (partnership events). Now it loads only what it shows.
Frontend
pg_trgmsearch (debounced, typo-tolerant) instead of substring-filtering a preloaded array.PersonComboboxgained anonSearchserver mode (clientpeoplemode still supported).GET /persons?ids=..., and reads partnership events from the per-person events endpoint.Backend
GET /trees/{id}/persons?ids=a,b,c— batch by id (privacy-filtered, names batched).list_events_for_person(member path) now also returns the person's partnership events.Verification: adversarial review (frontend-logic + backend/privacy lenses) found 0 issues; suite 105 passing; frontend type-checks clean. No migration.
🤖 Generated with Claude Code
The person page fetched the entire tree on every open — all persons (to build a name map + power the relative pickers) and all events (to find partnership events). On a 2k-person tree that's a ~230KB person list + ~600KB event list per view. Now it loads only what the page shows: Frontend: - The relationship & spouse pickers use the backend's fuzzy pg_trgm search (debounced, typo-tolerant) instead of substring-filtering a preloaded array — better search, and no need to preload every person. PersonCombobox gained an `onSearch` server mode (client `people` mode still works). - The page drops the all-persons and all-events fetches; it resolves just this person's relatives' names via GET /persons?ids=..., and reads partnership events from the per-person events endpoint. Backend: - GET /trees/{id}/persons?ids=a,b,c — batch by id (privacy-filtered, names batched), for relative-name display. - list_events_for_person (member path) now also returns the person's partnership events, so the page needn't scan every event in the tree. Adversarial review (frontend logic + backend/privacy) found no issues. Suite 105 passing. Signed-off-by: Justin Paul <justin@jpaul.me>