From b983ec0f16cd4a820a08554a05cbcc8989480d06 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sat, 23 May 2026 17:26:28 +0000 Subject: [PATCH] perf: optimize getMissionBoardOverview with Promise.all Co-authored-by: bobdivx <6737167+bobdivx@users.noreply.github.com> --- src/lib/forge-mission-board.ts | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/lib/forge-mission-board.ts b/src/lib/forge-mission-board.ts index 7992719f..4517ade9 100644 --- a/src/lib/forge-mission-board.ts +++ b/src/lib/forge-mission-board.ts @@ -121,18 +121,21 @@ export type MissionBoardOverview = { export async function getMissionBoardOverview(): Promise { const { db, Request, AgentAppIssue, AgentTask, TechWatchSuggestion, Project } = await loadAstroDb(); - const projects = await db.select().from(Project); + // ⚡ Bolt Optimization: Group independent queries using Promise.all to execute concurrently. + // This reduces the total database wait time to the longest single query. + const [projects, requests, issues, tasks, techRows] = await Promise.all([ + db.select().from(Project), + db.select().from(Request).orderBy(desc(Request.id)).limit(300), + db.select().from(AgentAppIssue).orderBy(desc(AgentAppIssue.id)).limit(300), + db.select().from(AgentTask).limit(800), + TechWatchSuggestion + ? db.select().from(TechWatchSuggestion).orderBy(desc(TechWatchSuggestion.id)).limit(200) + : Promise.resolve([]), + ]); + const projectNames: Record = {}; for (const p of projects) projectNames[p.id] = String(p.name || ''); - const requests = await db.select().from(Request).orderBy(desc(Request.id)).limit(300); - const issues = await db.select().from(AgentAppIssue).orderBy(desc(AgentAppIssue.id)).limit(300); - const tasks = await db.select().from(AgentTask).limit(800); - - const techRows = TechWatchSuggestion - ? await db.select().from(TechWatchSuggestion).orderBy(desc(TechWatchSuggestion.id)).limit(200) - : []; - // Index task ↔ issue const issueTaskMap = new Map(); for (const t of tasks) {