Skip to content

Commit 8f287d3

Browse files
d-csclaude
andcommitted
style(run-ops): apply oxfmt
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 60a540b commit 8f287d3

13 files changed

Lines changed: 315 additions & 191 deletions

apps/webapp/app/presenters/v3/BatchListPresenter.server.ts

Lines changed: 32 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -197,43 +197,38 @@ export class BatchListPresenter extends BasePresenter {
197197
}
198198
const createdAtLte: Date | undefined = time.to;
199199

200-
const batches = await this.#scanBatchTaskRun(
201-
pageSize,
202-
direction,
203-
(client) =>
204-
client.batchTaskRun.findMany({
205-
where: {
206-
runtimeEnvironmentId: environmentId,
207-
...(cursor
208-
? { id: direction === "forward" ? { lt: cursor } : { gt: cursor } }
209-
: {}),
210-
...(friendlyId ? { friendlyId } : {}),
211-
...(statuses && statuses.length > 0
212-
? { status: { in: statuses }, batchVersion: { not: "v1" } }
213-
: {}),
214-
...(createdAtGte !== undefined || createdAtLte !== undefined
215-
? {
216-
createdAt: {
217-
...(createdAtGte !== undefined ? { gte: createdAtGte } : {}),
218-
...(createdAtLte !== undefined ? { lte: createdAtLte } : {}),
219-
},
220-
}
221-
: {}),
222-
},
223-
orderBy: { id: direction === "forward" ? "desc" : "asc" },
224-
take: pageSize + 1,
225-
select: {
226-
id: true,
227-
friendlyId: true,
228-
runtimeEnvironmentId: true,
229-
status: true,
230-
createdAt: true,
231-
updatedAt: true,
232-
completedAt: true,
233-
runCount: true,
234-
batchVersion: true,
235-
},
236-
})
200+
const batches = await this.#scanBatchTaskRun(pageSize, direction, (client) =>
201+
client.batchTaskRun.findMany({
202+
where: {
203+
runtimeEnvironmentId: environmentId,
204+
...(cursor ? { id: direction === "forward" ? { lt: cursor } : { gt: cursor } } : {}),
205+
...(friendlyId ? { friendlyId } : {}),
206+
...(statuses && statuses.length > 0
207+
? { status: { in: statuses }, batchVersion: { not: "v1" } }
208+
: {}),
209+
...(createdAtGte !== undefined || createdAtLte !== undefined
210+
? {
211+
createdAt: {
212+
...(createdAtGte !== undefined ? { gte: createdAtGte } : {}),
213+
...(createdAtLte !== undefined ? { lte: createdAtLte } : {}),
214+
},
215+
}
216+
: {}),
217+
},
218+
orderBy: { id: direction === "forward" ? "desc" : "asc" },
219+
take: pageSize + 1,
220+
select: {
221+
id: true,
222+
friendlyId: true,
223+
runtimeEnvironmentId: true,
224+
status: true,
225+
createdAt: true,
226+
updatedAt: true,
227+
completedAt: true,
228+
runCount: true,
229+
batchVersion: true,
230+
},
231+
})
237232
);
238233

239234
const hasMore = batches.length > pageSize;

apps/webapp/app/presenters/v3/WaitpointListPresenter.server.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,8 @@ export class WaitpointListPresenter extends BasePresenter {
170170
}
171171
if (from !== undefined) {
172172
const fromDate = new Date(from);
173-
createdAtGte = createdAtGte === undefined ? fromDate : fromDate > createdAtGte ? fromDate : createdAtGte;
173+
createdAtGte =
174+
createdAtGte === undefined ? fromDate : fromDate > createdAtGte ? fromDate : createdAtGte;
174175
}
175176
const createdAtLte: Date | undefined = to !== undefined ? new Date(to) : undefined;
176177

@@ -180,9 +181,7 @@ export class WaitpointListPresenter extends BasePresenter {
180181
where: {
181182
environmentId: environment.id,
182183
type: "MANUAL",
183-
...(cursor
184-
? { id: direction === "forward" ? { lt: cursor } : { gt: cursor } }
185-
: {}),
184+
...(cursor ? { id: direction === "forward" ? { lt: cursor } : { gt: cursor } } : {}),
186185
...(id ? { friendlyId: id } : {}),
187186
...(statusesToFilter.length ? { status: { in: statusesToFilter } } : {}),
188187
...(filterOutputIsError !== undefined ? { outputIsError: filterOutputIsError } : {}),

apps/webapp/test/apiRunResultPresenter.readthrough.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,7 @@ async function seedEnv(prisma: PrismaClient, slug: string) {
8282
return { organization, project, environment };
8383
}
8484

85-
async function seedWorker(
86-
prisma: PrismaClient,
87-
ctx: { environmentId: string; projectId: string }
88-
) {
85+
async function seedWorker(prisma: PrismaClient, ctx: { environmentId: string; projectId: string }) {
8986
const queue = await prisma.taskQueue.create({
9087
data: {
9188
friendlyId: `queue_${idGenerator()}`,

apps/webapp/test/apiWaitpointPresenter.readthrough.test.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,10 @@ describe("ApiWaitpointPresenter read-through (heterogeneous legacy + new Postgre
225225
newClient: recording(prisma17).handle,
226226
legacyReplica: newLegacy.handle,
227227
});
228-
const migratedResult = await migratedPresenter.call(environmentArg(newEnv.environment), newId);
228+
const migratedResult = await migratedPresenter.call(
229+
environmentArg(newEnv.environment),
230+
newId
231+
);
229232
expect(migratedResult.id).toBe(`waitpoint_${newId}`);
230233
expect(newLegacy.calls.length).toBe(0);
231234

@@ -241,7 +244,10 @@ describe("ApiWaitpointPresenter read-through (heterogeneous legacy + new Postgre
241244
newClient: recording(prisma17).handle,
242245
legacyReplica: recording(prisma14).handle,
243246
});
244-
const retentionResult = await retentionPresenter.call(environmentArg(oldEnv.environment), oldId);
247+
const retentionResult = await retentionPresenter.call(
248+
environmentArg(oldEnv.environment),
249+
oldId
250+
);
245251
expect(retentionResult.id).toBe(`waitpoint_${oldId}`);
246252
}
247253
);

apps/webapp/test/batchListPresenter.readroute.test.ts

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ vi.mock("~/db.server", () => ({
1313
sqlDatabaseSchema: Prisma.sql(["public"]),
1414
}));
1515

16-
import { heteroPostgresTest, heteroRunOpsPostgresTest, postgresTest } from "@internal/testcontainers";
16+
import {
17+
heteroPostgresTest,
18+
heteroRunOpsPostgresTest,
19+
postgresTest,
20+
} from "@internal/testcontainers";
1721
import { PrismaClient } from "@trigger.dev/database";
1822
import { RunOpsPrismaClient } from "@internal/run-ops-database";
1923
import {
@@ -34,7 +38,12 @@ type SeedContext = {
3438
// against a direct $queryRaw of the identical SQL on each DB version.
3539
function rawScan(
3640
prisma: PrismaClient,
37-
opts: { environmentId: string; pageSize: number; direction: "forward" | "backward"; cursor?: string }
41+
opts: {
42+
environmentId: string;
43+
pageSize: number;
44+
direction: "forward" | "backward";
45+
cursor?: string;
46+
}
3847
) {
3948
const { environmentId, pageSize, direction, cursor } = opts;
4049
const sqlDatabaseSchema = Prisma.sql(["public"]);
@@ -178,7 +187,10 @@ async function createBatch(
178187
});
179188
}
180189

181-
const baseCall = (ctx: SeedContext, overrides: Partial<BatchListOptions> = {}): BatchListOptions => ({
190+
const baseCall = (
191+
ctx: SeedContext,
192+
overrides: Partial<BatchListOptions> = {}
193+
): BatchListOptions => ({
182194
projectId: ctx.projectId,
183195
environmentId: ctx.environmentId,
184196
userId: ctx.userId,
@@ -201,7 +213,8 @@ function spyClient(
201213
if (trProp === "findMany") {
202214
return (...args: any[]) => {
203215
counts.findMany++;
204-
if (opts.throwOnQueryRaw) throw new Error("batchTaskRun.findMany must not be invoked on this handle");
216+
if (opts.throwOnQueryRaw)
217+
throw new Error("batchTaskRun.findMany must not be invoked on this handle");
205218
return (trTarget as any).findMany(...args);
206219
};
207220
}
@@ -286,7 +299,11 @@ describe("BatchListPresenter run-ops read routing (PG14 control-plane/legacy + P
286299
// The TS codepoint comparator reproduces the DB ORDER BY over the seeded id set.
287300
const allIds = ids.map((i) => `batch_${i}`);
288301
const dbForward = (
289-
await rawScan(prisma17, { environmentId: ctx17.environmentId, pageSize: 50, direction: "forward" })
302+
await rawScan(prisma17, {
303+
environmentId: ctx17.environmentId,
304+
pageSize: 50,
305+
direction: "forward",
306+
})
290307
).map((r) => r.id);
291308
expect(dbForward).toEqual([...allIds].sort(desc));
292309
}
@@ -389,7 +406,9 @@ describe("BatchListPresenter run-ops read routing (PG14 control-plane/legacy + P
389406
expect(page.hasAnyBatches).toBe(true);
390407

391408
// Now wipe legacy too => both empty => hasAnyBatches false.
392-
await prisma14.batchTaskRun.deleteMany({ where: { runtimeEnvironmentId: ctx.environmentId } });
409+
await prisma14.batchTaskRun.deleteMany({
410+
where: { runtimeEnvironmentId: ctx.environmentId },
411+
});
393412
const page2 = await presenter.call(baseCall(ctx, { friendlyId: "fr_does_not_exist" }));
394413
expect(page2.batches).toHaveLength(0);
395414
expect(page2.hasAnyBatches).toBe(false);

apps/webapp/test/batchPresenter.test.ts

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -333,27 +333,28 @@ describe("BatchPresenter single-DB passthrough", () => {
333333
// TaskRuns — the dangling-reference gate over members is owned by the migration / dangling-gate
334334
// units, not this presenter. This unit's contribution is "batch detail loads regardless of
335335
// which run-ops store holds the batch row."
336-
containerTest("e2e #3 proxy: a batch spanning migrated + abandoned runs still resolves", async ({
337-
prisma,
338-
}) => {
339-
const ctx = await seedEnvironment(prisma, "e2e3");
340-
await seedBatch(prisma, ctx.environmentId, {
341-
friendlyId: "batch_e2e3",
342-
runCount: 10, // implies members spanning migrated + abandoned runs
343-
});
336+
containerTest(
337+
"e2e #3 proxy: a batch spanning migrated + abandoned runs still resolves",
338+
async ({ prisma }) => {
339+
const ctx = await seedEnvironment(prisma, "e2e3");
340+
await seedBatch(prisma, ctx.environmentId, {
341+
friendlyId: "batch_e2e3",
342+
runCount: 10, // implies members spanning migrated + abandoned runs
343+
});
344344

345-
const presenter = new BatchPresenter(prisma, prisma, {
346-
splitEnabled: false,
347-
newClient: prisma,
348-
resolveDisplayableEnvironment: makeEnvResolver(prisma),
349-
});
345+
const presenter = new BatchPresenter(prisma, prisma, {
346+
splitEnabled: false,
347+
newClient: prisma,
348+
resolveDisplayableEnvironment: makeEnvResolver(prisma),
349+
});
350350

351-
const result = await presenter.call({
352-
environmentId: ctx.environmentId,
353-
batchId: "batch_e2e3",
354-
});
351+
const result = await presenter.call({
352+
environmentId: ctx.environmentId,
353+
batchId: "batch_e2e3",
354+
});
355355

356-
expect(result.friendlyId).toBe("batch_e2e3");
357-
expect(result.runCount).toBe(10);
358-
});
356+
expect(result.friendlyId).toBe("batch_e2e3");
357+
expect(result.runCount).toBe(10);
358+
}
359+
);
359360
});

apps/webapp/test/nextRunListPresenter.readthrough.test.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,11 @@ describe("NextRunListPresenter dual-DB empty-state probe + routed hydrate (legac
206206
splitEnabled: true,
207207
});
208208

209-
const result = await presenter.call(ctx.organizationId, ctx.environmentId, callOptions(ctx));
209+
const result = await presenter.call(
210+
ctx.organizationId,
211+
ctx.environmentId,
212+
callOptions(ctx)
213+
);
210214

211215
// CH id-set is empty within the page window, but the legacy probe finds the row.
212216
expect(result.runs).toHaveLength(0);
@@ -253,7 +257,11 @@ describe("NextRunListPresenter dual-DB empty-state probe + routed hydrate (legac
253257
});
254258

255259
// If the legacy spy were invoked, this would throw — the test passing IS the proof.
256-
const result = await presenter.call(ctx.organizationId, ctx.environmentId, callOptions(ctx));
260+
const result = await presenter.call(
261+
ctx.organizationId,
262+
ctx.environmentId,
263+
callOptions(ctx)
264+
);
257265

258266
expect(result.runs).toHaveLength(0);
259267
expect(result.hasAnyRuns).toBe(true);
@@ -291,7 +299,11 @@ describe("NextRunListPresenter dual-DB empty-state probe + routed hydrate (legac
291299
splitEnabled: true,
292300
});
293301

294-
const result = await presenter.call(ctx.organizationId, ctx.environmentId, callOptions(ctx));
302+
const result = await presenter.call(
303+
ctx.organizationId,
304+
ctx.environmentId,
305+
callOptions(ctx)
306+
);
295307

296308
expect(result.runs).toHaveLength(0);
297309
expect(result.hasAnyRuns).toBe(false);
@@ -392,7 +404,11 @@ describe("NextRunListPresenter dual-DB empty-state probe + routed hydrate (legac
392404
splitEnabled: true,
393405
});
394406

395-
const result = await presenter.call(ctx.organizationId, ctx.environmentId, callOptions(ctx));
407+
const result = await presenter.call(
408+
ctx.organizationId,
409+
ctx.environmentId,
410+
callOptions(ctx)
411+
);
396412

397413
const expectedIds = [migratedA.id, migratedB.id, legacyOnlyA.id, legacyOnlyB.id].sort(
398414
(a, b) => (a < b ? 1 : a > b ? -1 : 0)

apps/webapp/test/presenters/TestTaskPresenter.readthrough.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,5 +511,4 @@ describe("TestTaskPresenter recent-payloads read-through (PG14 legacy + PG17 new
511511
}
512512
}
513513
);
514-
515514
});

apps/webapp/test/realtime/clickHouseRunListResolver.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,11 @@ describe("ClickHouseRunListResolver (realtime run-list id-set, split-neutral)",
362362
const otherEnvId = await seedSecondEnvironment(prisma, ctx, "envscope");
363363

364364
const inEnv = await createRun(prisma, ctx, { friendlyId: "run_inEnv" });
365-
await createRun(prisma, { ...ctx, environmentId: otherEnvId }, { friendlyId: "run_otherEnv" });
365+
await createRun(
366+
prisma,
367+
{ ...ctx, environmentId: otherEnvId },
368+
{ friendlyId: "run_otherEnv" }
369+
);
366370

367371
await setTimeout(1500);
368372

0 commit comments

Comments
 (0)