Skip to content

Commit af76548

Browse files
committed
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.
1 parent edceebe commit af76548

3 files changed

Lines changed: 9 additions & 11 deletions

File tree

apps/api/src/service.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import { logger } from "./logger";
33
const baseUrl = process.env.INNGEST_BASE_URL ?? "";
44
const signingKey = process.env.INNGEST_SIGNING_KEY ?? "";
55

6+
const DEFAULT_MAX_EVENTS = 500;
7+
const MAX_EVENTS = DEFAULT_MAX_EVENTS;
8+
69
/** Event shape from GET /v1/events (https://api.inngest.com/v1/events) */
710
type InngestEventRow = {
811
internal_id?: string;
@@ -232,9 +235,5 @@ export const fetchDeploymentJobs = async (
232235
}),
233236
);
234237

235-
return buildDeploymentRowsFromRuns(events, runsByEventId, serverId);
238+
return buildDeploymentRowsFromRuns(toFetch, runsByEventId, serverId);
236239
};
237-
238-
const DEFAULT_MAX_EVENTS = 500;
239-
240-
const MAX_EVENTS = DEFAULT_MAX_EVENTS;

apps/dokploy/components/dashboard/deployments/show-queue-table.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ export function ShowQueueTable(props: { embedded?: boolean }) {
197197
})
198198
) : (
199199
<TableRow>
200-
<TableCell colSpan={10} className="text-center py-12">
200+
<TableCell colSpan={9} className="text-center py-12">
201201
<div className="flex flex-col items-center justify-center gap-2 text-muted-foreground min-h-[30vh]">
202202
<ListTodo className="size-8" />
203203
<p className="font-medium">Queue is empty</p>

apps/dokploy/server/api/routers/deployment.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,10 @@ export const deploymentRouter = createTRPCRouter({
9696
where: eq(server.organizationId, orgId),
9797
columns: { serverId: true },
9898
});
99-
rows = [];
100-
for (const { serverId } of servers) {
101-
const serverRows = await fetchDeployApiJobs(serverId);
102-
rows.push(...serverRows);
103-
}
99+
const serverRowsArrays = await Promise.all(
100+
servers.map(({ serverId }) => fetchDeployApiJobs(serverId)),
101+
);
102+
rows = serverRowsArrays.flat();
104103
rows.sort((a, b) => (b.timestamp ?? 0) - (a.timestamp ?? 0));
105104
} else {
106105
const jobs = await myQueue.getJobs();

0 commit comments

Comments
 (0)