Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .jules/bolt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 2026-05-01 - Concurrent Fetching in Share API
**Learning:** Sequential database queries (like `listUserShares` followed by `getUserLists` and `getUserProjects`) create unnecessary waterfall latency, especially for independent datasets.
**Action:** Always group independent async database calls using `Promise.all` to reduce total latency, as done in `GET /api/share`.
10 changes: 7 additions & 3 deletions src/app/api/share/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@ export async function GET() {
);
}

const shares = await listUserShares(userId);
// Fetch shares, lists, and projects concurrently to minimize database latency
// and resolve the waterfall fetching pattern.
const [shares, lists, projects] = await Promise.all([
listUserShares(userId),
getUserLists(userId),
getUserProjects(userId),
]);

// Enrich with target name so the UI can render without extra round-trips.
const lists = await getUserLists(userId);
const projects = await getUserProjects(userId);
const listById = new Map(lists.map((l) => [l.id, l]));
const projectById = new Map(projects.map((p) => [p.id, p]));

Expand Down
Loading