vinterliste/server
Ole-Morten Duesund c7365b46ed perf(activities): bulk-fetch list serialisation (N+1 → constant)
The /api/activities list endpoint serialised each row by calling
tagsFor, heartsFor, viewerBookmarked, and ownerAttribution — that's
~5 queries per row. For a list of N activities the endpoint issued
5N queries; for a hundred-row list, hundreds of round-trips.

Add buildBulkLookups(rows, viewerId) that runs one IN-query per
concern (tags, heart counts, viewer-hearted, viewer-bookmarked,
owner attribution) and returns precomputed maps. serialize() now
accepts an optional bulk arg; single-row paths (GET /:id, POST,
PATCH, heart/bookmark toggles) pass undefined and keep their per-row
helpers — fine for one row, wrong for a list.

Also add bulkTagsFor() to server/tags.ts as a reusable helper, and
apply the same treatment to server/users.ts (public-list endpoint
had a 2N pattern on tags + heart counts).

Surfaced by /audit simplify.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-25 17:45:46 +02:00
..
activities.ts perf(activities): bulk-fetch list serialisation (N+1 → constant) 2026-05-25 17:45:46 +02:00
admin.ts Admin role, root/home URL split, activity permalinks 2026-05-25 13:23:13 +02:00
auth.ts External profile links (max 5 per user) 2026-05-25 16:20:04 +02:00
db.ts Drag-and-drop unified activity list with per-user sort order 2026-05-25 16:47:55 +02:00
feedback.ts fix(feedback): stop exposing done_by user id in API responses 2026-05-25 13:54:07 +02:00
friends.ts Friends + friends-only visibility + blocking 2026-05-25 14:47:20 +02:00
index.ts OpenGraph meta on the SPA's shareable routes 2026-05-25 16:05:43 +02:00
invites.ts fix(invites): build share URL on the client, not the server 2026-05-25 16:25:55 +02:00
og.ts OpenGraph meta on the SPA's shareable routes 2026-05-25 16:05:43 +02:00
roles.ts Admin role, root/home URL split, activity permalinks 2026-05-25 13:23:13 +02:00
session.ts Scaffold Vinterliste — end-to-end encrypted winter activity list 2026-05-25 12:27:14 +02:00
settings.ts Self-registry toggle, invite links with attribution, first-user-admin 2026-05-25 13:45:32 +02:00
tags.ts perf(activities): bulk-fetch list serialisation (N+1 → constant) 2026-05-25 17:45:46 +02:00
users.ts perf(activities): bulk-fetch list serialisation (N+1 → constant) 2026-05-25 17:45:46 +02:00