Skip to content

Commit 9d24fc1

Browse files
committed
optimise worker auth query
1 parent d6e8743 commit 9d24fc1

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

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

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,24 +52,20 @@ export class WorkerGroupTokenService extends WithRunEngine {
5252
async findWorkerGroup({ token }: { token: string }) {
5353
const tokenHash = await this.hashToken(token);
5454

55-
const workerGroupToken = await this._prisma.workerGroupToken.findFirst({
55+
const workerGroup = await this._prisma.workerInstanceGroup.findFirst({
5656
where: {
57-
workerGroup: {
58-
isNot: null,
57+
token: {
58+
tokenHash,
5959
},
60-
tokenHash,
61-
},
62-
include: {
63-
workerGroup: true,
6460
},
6561
});
6662

67-
if (!workerGroupToken) {
68-
logger.warn("[WorkerGroupTokenService] Token not found", { token });
69-
return;
63+
if (!workerGroup) {
64+
logger.warn("[WorkerGroupTokenService] No matching worker group found", { token });
65+
return null;
7066
}
7167

72-
return workerGroupToken.workerGroup;
68+
return workerGroup;
7369
}
7470

7571
async rotateToken({ workerGroupId }: { workerGroupId: string }) {

0 commit comments

Comments
 (0)