Skip to content

Commit 1e9372f

Browse files
carderneTrigger.dev RepoOps
authored andcommitted
fix(webapp): cast concurrency limits in allocation query
Mono-RevId: 91cf6369dd693fc72a235b7c59cb238e61210231
1 parent d69eac2 commit 1e9372f

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

‎apps/webapp/app/v3/services/allocateConcurrency.server.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ async function computeOrgExtraAllocatedConcurrency(
363363
}
364364

365365
const limitCases = Prisma.join(
366-
typeLimits.map((entry) => Prisma.sql`WHEN ${entry.type}::text THEN ${entry.limit}`),
366+
typeLimits.map((entry) => Prisma.sql`WHEN ${entry.type}::text THEN ${entry.limit}::integer`),
367367
" "
368368
);
369369
const countableTypes = Prisma.join(typeLimits.map((entry) => entry.type));

‎apps/webapp/test/allocateConcurrency.test.ts‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { postgresTest } from "@internal/testcontainers";
1+
import { postgresBlipTest, postgresTest } from "@internal/testcontainers";
22
import type { PrismaClient } from "@trigger.dev/database";
33
import { describe, expect, vi } from "vitest";
44
import { ManageConcurrencyPresenter } from "~/presenters/v3/ManageConcurrencyPresenter.server";
@@ -176,6 +176,21 @@ describe("AllocateConcurrencyService", () => {
176176
}
177177
);
178178

179+
postgresBlipTest("allocates with the production database adapter", async ({ prisma }) => {
180+
const { organization, project, environments } = await seedProjectWithEnvironments(prisma, 1);
181+
getCurrentPlanMock.mockResolvedValue(planWithPurchasedConcurrency(10));
182+
183+
const service = new AllocateConcurrencyService(prisma);
184+
const result = await service.call({
185+
userId: "user_1",
186+
projectId: project.id,
187+
organizationId: organization.id,
188+
environments: [{ id: environments[0].id, amount: 1 }],
189+
});
190+
191+
expect(result).toEqual({ success: true });
192+
});
193+
179194
postgresTest(
180195
"rejects an allocation that exceeds the unallocated pool and syncs nothing",
181196
async ({ prisma }) => {

0 commit comments

Comments
 (0)