Skip to content

Commit 0bf1311

Browse files
committed
PS-489 - when receiving SubmissionScanCompleteHandler, check if ai workflows have already been queued. if so, prevent further queueing
1 parent ba865b2 commit 0bf1311

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/shared/modules/global/submission-scan-complete.orchestrator.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,18 @@ export class SubmissionScanCompleteOrchestrator {
4949
return;
5050
}
5151

52+
// check if workflow runs have already been queued for this submission
53+
const alreadyQueued = await this.workflowQueueHandler.hasQueuedWorkflowRuns(
54+
submissionId,
55+
);
56+
57+
if (alreadyQueued) {
58+
this.logger.log(
59+
`AI workflow runs already queued for submission ${submissionId}. Skipping queueing.`,
60+
);
61+
return;
62+
}
63+
5264
await this.workflowQueueHandler.queueWorkflowRuns(
5365
challenge.workflows,
5466
challenge.id,

src/shared/modules/global/workflow-queue.handler.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,18 @@ export class WorkflowQueueHandler implements OnModuleInit {
7979
});
8080
}
8181

82+
async hasQueuedWorkflowRuns(submissionId: string): Promise<boolean> {
83+
if (!submissionId) return false;
84+
85+
const existing = await this.prisma.aiWorkflowRun.findFirst({
86+
where: {
87+
submissionId,
88+
},
89+
});
90+
91+
return !!existing;
92+
}
93+
8294
async handleQueuedWorkflowRun([job]: [Job]) {
8395
this.logger.log(`Processing job ${job.id}`);
8496

0 commit comments

Comments
 (0)