Skip to content

Commit 085c53a

Browse files
committed
Removed findUniques from WorkerGroupTokenService
1 parent 42f69d5 commit 085c53a

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

apps/webapp/app/v3/services/worker/workerGroupTokenService.server.ts

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export class WorkerGroupTokenService extends WithRunEngine {
7373
}
7474

7575
async rotateToken({ workerGroupId }: { workerGroupId: string }) {
76-
const workerGroup = await this._prisma.workerInstanceGroup.findUnique({
76+
const workerGroup = await this._prisma.workerInstanceGroup.findFirst({
7777
where: {
7878
id: workerGroupId,
7979
},
@@ -266,12 +266,10 @@ export class WorkerGroupTokenService extends WithRunEngine {
266266
return await $transaction(this._prisma, async (tx) => {
267267
const resourceIdentifier = deploymentId ? `${deploymentId}:${instanceName}` : instanceName;
268268

269-
const workerInstance = await tx.workerInstance.findUnique({
269+
const workerInstance = await tx.workerInstance.findFirst({
270270
where: {
271-
workerGroupId_resourceIdentifier: {
272-
workerGroupId: workerGroup.id,
273-
resourceIdentifier,
274-
},
271+
workerGroupId: workerGroup.id,
272+
resourceIdentifier,
275273
},
276274
include: {
277275
deployment: true,
@@ -315,12 +313,10 @@ export class WorkerGroupTokenService extends WithRunEngine {
315313
// Unique constraint violation
316314
if (error.code === "P2002") {
317315
try {
318-
const existingWorkerInstance = await tx.workerInstance.findUnique({
316+
const existingWorkerInstance = await tx.workerInstance.findFirst({
319317
where: {
320-
workerGroupId_resourceIdentifier: {
321-
workerGroupId: workerGroup.id,
322-
resourceIdentifier,
323-
},
318+
workerGroupId: workerGroup.id,
319+
resourceIdentifier,
324320
},
325321
include: {
326322
deployment: true,
@@ -363,7 +359,7 @@ export class WorkerGroupTokenService extends WithRunEngine {
363359

364360
// Unmanaged workers instances are locked to a specific deployment version
365361

366-
const deployment = await tx.workerDeployment.findUnique({
362+
const deployment = await tx.workerDeployment.findFirst({
367363
where: {
368364
...(deploymentId.startsWith("deployment_")
369365
? {
@@ -690,7 +686,7 @@ export class AuthenticatedWorkerInstance extends WithRunEngine {
690686

691687
const environment =
692688
this.environment ??
693-
(await this._prisma.runtimeEnvironment.findUnique({
689+
(await this._prisma.runtimeEnvironment.findFirst({
694690
where: {
695691
id: engineResult.execution.environment.id,
696692
},

0 commit comments

Comments
 (0)