From af765484829cbb5e21d7450d3beb11b6e85364e2 Mon Sep 17 00:00:00 2001 From: Mauricio Siu Date: Tue, 3 Mar 2026 14:09:46 -0600 Subject: [PATCH] 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. --- apps/api/src/service.ts | 9 ++++----- .../dashboard/deployments/show-queue-table.tsx | 2 +- apps/dokploy/server/api/routers/deployment.ts | 9 ++++----- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/apps/api/src/service.ts b/apps/api/src/service.ts index 2890ecf6b..495e30ca3 100644 --- a/apps/api/src/service.ts +++ b/apps/api/src/service.ts @@ -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; diff --git a/apps/dokploy/components/dashboard/deployments/show-queue-table.tsx b/apps/dokploy/components/dashboard/deployments/show-queue-table.tsx index f86df48b0..e46b33a6a 100644 --- a/apps/dokploy/components/dashboard/deployments/show-queue-table.tsx +++ b/apps/dokploy/components/dashboard/deployments/show-queue-table.tsx @@ -197,7 +197,7 @@ export function ShowQueueTable(props: { embedded?: boolean }) { }) ) : ( - +

Queue is empty

diff --git a/apps/dokploy/server/api/routers/deployment.ts b/apps/dokploy/server/api/routers/deployment.ts index 30b5b97f8..7b2b414c0 100644 --- a/apps/dokploy/server/api/routers/deployment.ts +++ b/apps/dokploy/server/api/routers/deployment.ts @@ -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();