refactor: streamline event fetching and improve UI table layout

Updated the event fetching logic to utilize Promise.all for concurrent API calls, enhancing performance. Adjusted the UI table layout by modifying the column span for better alignment and presentation of the empty queue state. Introduced constants for maximum events to improve code clarity.
This commit is contained in:
Mauricio Siu
2026-03-03 14:09:46 -06:00
parent edceebec7e
commit af76548482
3 changed files with 9 additions and 11 deletions

View File

@@ -3,6 +3,9 @@ import { logger } from "./logger";
const baseUrl = process.env.INNGEST_BASE_URL ?? "";
const signingKey = process.env.INNGEST_SIGNING_KEY ?? "";
const DEFAULT_MAX_EVENTS = 500;
const MAX_EVENTS = DEFAULT_MAX_EVENTS;
/** Event shape from GET /v1/events (https://api.inngest.com/v1/events) */
type InngestEventRow = {
internal_id?: string;
@@ -232,9 +235,5 @@ export const fetchDeploymentJobs = async (
}),
);
return buildDeploymentRowsFromRuns(events, runsByEventId, serverId);
return buildDeploymentRowsFromRuns(toFetch, runsByEventId, serverId);
};
const DEFAULT_MAX_EVENTS = 500;
const MAX_EVENTS = DEFAULT_MAX_EVENTS;

View File

@@ -197,7 +197,7 @@ export function ShowQueueTable(props: { embedded?: boolean }) {
})
) : (
<TableRow>
<TableCell colSpan={10} className="text-center py-12">
<TableCell colSpan={9} className="text-center py-12">
<div className="flex flex-col items-center justify-center gap-2 text-muted-foreground min-h-[30vh]">
<ListTodo className="size-8" />
<p className="font-medium">Queue is empty</p>

View File

@@ -96,11 +96,10 @@ export const deploymentRouter = createTRPCRouter({
where: eq(server.organizationId, orgId),
columns: { serverId: true },
});
rows = [];
for (const { serverId } of servers) {
const serverRows = await fetchDeployApiJobs(serverId);
rows.push(...serverRows);
}
const serverRowsArrays = await Promise.all(
servers.map(({ serverId }) => fetchDeployApiJobs(serverId)),
);
rows = serverRowsArrays.flat();
rows.sort((a, b) => (b.timestamp ?? 0) - (a.timestamp ?? 0));
} else {
const jobs = await myQueue.getJobs();