Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions apps/webapp/app/runEngine/services/batchTrigger.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -564,20 +564,27 @@ export class RunEngineBatchTriggerService extends WithRunEngine {
runIds: {
push: runIds,
},
processingJobsCount: {
increment: runIds.length,
},
},
select: {
processingJobsCount: true,
runCount: true,
},
});

// if there are more items to process, requeue the batch
if (workingIndex < batch.runCount) {
return { status: "INCOMPLETE", workingIndex };
}

//triggered all the runs
if (updatedBatch.runIds.length === updatedBatch.runCount) {
if (updatedBatch.processingJobsCount >= updatedBatch.runCount) {
//if all the runs were idempotent, it's possible the batch is already completed
await this._engine.tryCompleteBatch({ batchId: batch.id });
}

// if there are more items to process, requeue the batch
if (workingIndex < batch.runCount) {
return { status: "INCOMPLETE", workingIndex };
}

return { status: "COMPLETE" };
}

Expand Down