Skip to content
Open
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
21 changes: 12 additions & 9 deletions src/lib/forge-mission-board.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,18 +121,21 @@ export type MissionBoardOverview = {
export async function getMissionBoardOverview(): Promise<MissionBoardOverview> {
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),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The query for AgentTask is missing an orderBy clause. Without explicit ordering, the limit(800) might return an arbitrary set of records (often the oldest ones) depending on the database engine's implementation. For a mission board that tracks current work, it is important to fetch the most recent tasks to ensure that the mapping between issues and tasks (used later in issueTaskMap) reflects the latest status. Adding orderBy(desc(AgentTask.id)) would make this consistent with the other queries in this block and ensure data freshness.

Suggested change
db.select().from(AgentTask).limit(800),
db.select().from(AgentTask).orderBy(desc(AgentTask.id)).limit(800),

TechWatchSuggestion
? db.select().from(TechWatchSuggestion).orderBy(desc(TechWatchSuggestion.id)).limit(200)
: Promise.resolve([]),
]);

const projectNames: Record<number, string> = {};
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<number, { id: number; status: string }>();
for (const t of tasks) {
Expand Down