Skip to content

Commit 6dd0256

Browse files
committed
fix(webapp): limit rows interleave only on the dashboard list
The public queues API and the runs filter resources share the list presenter, so the limit interleaving is opt-in and only the dashboard Concurrency page passes it; every other caller stays queue-only.
1 parent 70be770 commit 6dd0256

2 files changed

Lines changed: 36 additions & 14 deletions

File tree

‎apps/webapp/app/presenters/v3/QueueListPresenter.server.ts‎

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,18 @@ function formatClickhouseDateTime(date: Date): string {
7979
function buildQueueListWhere(
8080
environmentId: string,
8181
query: string | undefined,
82-
type: "task" | "custom" | undefined
82+
type: "task" | "custom" | undefined,
83+
includeLimits: boolean
8384
): Prisma.TaskQueueWhereInput {
8485
const trimmedQuery = query?.trim();
8586

8687
return {
8788
runtimeEnvironmentId: environmentId,
88-
/** The type filter names queue shapes, so applying it scopes the list to queue rows;
89-
* without it the list interleaves named limits alongside queues. */
90-
role: type ? ("QUEUE" as const) : { in: ["QUEUE" as const, "LIMIT" as const] },
89+
/** Only the dashboard interleaves named limits, and the type filter names queue
90+
* shapes, so either condition scopes the list to queue rows; the public queues
91+
* API always stays queue-only. */
92+
role:
93+
includeLimits && !type ? { in: ["QUEUE" as const, "LIMIT" as const] } : ("QUEUE" as const),
9194
version: "V2",
9295
name: trimmedQuery
9396
? {
@@ -120,20 +123,29 @@ export class QueueListPresenter extends BasePresenter {
120123
page,
121124
type,
122125
sort = "name",
126+
includeLimits = false,
123127
}: {
124128
environment: AuthenticatedEnvironment;
125129
query?: string;
126130
page: number;
127131
perPage?: number;
128132
type?: "task" | "custom";
129133
sort?: QueueListSort;
134+
includeLimits?: boolean;
130135
}): Promise<QueueListResult> {
131136
const hasFilters = Boolean(query?.trim()) || type !== undefined;
132137

133138
if (sort !== "name") {
134139
// Ranking is additive: any failure or unsupported input falls back to name order.
135140
try {
136-
const ranked = await this.getRankedQueues(environment, query, page, type, sort);
141+
const ranked = await this.getRankedQueues(
142+
environment,
143+
query,
144+
page,
145+
type,
146+
sort,
147+
includeLimits
148+
);
137149
if (ranked) {
138150
return ranked;
139151
}
@@ -143,7 +155,13 @@ export class QueueListPresenter extends BasePresenter {
143155
}
144156

145157
if (hasFilters) {
146-
const { queues, hasMore } = await this.getFilteredQueues(environment, query, page, type);
158+
const { queues, hasMore } = await this.getFilteredQueues(
159+
environment,
160+
query,
161+
page,
162+
type,
163+
includeLimits
164+
);
147165

148166
return {
149167
queues,
@@ -157,11 +175,11 @@ export class QueueListPresenter extends BasePresenter {
157175
}
158176

159177
const totalQueues = await this._replica.taskQueue.count({
160-
where: buildQueueListWhere(environment.id, query, type),
178+
where: buildQueueListWhere(environment.id, query, type, includeLimits),
161179
});
162180

163181
return {
164-
queues: await this.getUnfilteredQueues(environment, page, type),
182+
queues: await this.getUnfilteredQueues(environment, page, type, includeLimits),
165183
pagination: {
166184
mode: "unfiltered" as const,
167185
currentPage: page,
@@ -182,7 +200,8 @@ export class QueueListPresenter extends BasePresenter {
182200
query: string | undefined,
183201
page: number,
184202
type: "task" | "custom" | undefined,
185-
sort: Exclude<QueueListSort, "name">
203+
sort: Exclude<QueueListSort, "name">,
204+
includeLimits: boolean
186205
) {
187206
if (type !== undefined) {
188207
return null;
@@ -231,7 +250,7 @@ export class QueueListPresenter extends BasePresenter {
231250
return null;
232251
}
233252

234-
const where = buildQueueListWhere(environment.id, query, type);
253+
const where = buildQueueListWhere(environment.id, query, type, includeLimits);
235254
const totalQueues = await this._replica.taskQueue.count({ where });
236255

237256
let rankedPageQueues: QueueListRow[] = [];
@@ -302,10 +321,11 @@ export class QueueListPresenter extends BasePresenter {
302321
environment: AuthenticatedEnvironment,
303322
query: string | undefined,
304323
page: number,
305-
type: "task" | "custom" | undefined
324+
type: "task" | "custom" | undefined,
325+
includeLimits: boolean
306326
) {
307327
const queues = await this._replica.taskQueue.findMany({
308-
where: buildQueueListWhere(environment.id, query, type),
328+
where: buildQueueListWhere(environment.id, query, type, includeLimits),
309329
select: queueListSelect,
310330
orderBy: {
311331
orderableName: "asc",
@@ -325,10 +345,11 @@ export class QueueListPresenter extends BasePresenter {
325345
private async getUnfilteredQueues(
326346
environment: AuthenticatedEnvironment,
327347
page: number,
328-
type: "task" | "custom" | undefined
348+
type: "task" | "custom" | undefined,
349+
includeLimits: boolean
329350
) {
330351
const queues = await this._replica.taskQueue.findMany({
331-
where: buildQueueListWhere(environment.id, undefined, type),
352+
where: buildQueueListWhere(environment.id, undefined, type, includeLimits),
332353
select: queueListSelect,
333354
orderBy: {
334355
orderableName: "asc",

‎apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.concurrency/route.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ export const loader = async ({ request, params }: LoaderFunctionArgs) => {
191191
environment,
192192
query,
193193
page,
194+
includeLimits: true,
194195
// Relevance ordering rides the metrics pipeline, so it is part of the gated UI.
195196
sort: queueMetricsUiEnabled ? (sort ?? "busiest") : "name",
196197
});

0 commit comments

Comments
 (0)