- const newRunnerJob = await sequelizeTypescript.transaction(transaction => {
- return runnerJob.save({ transaction })
+ if (runnerJob.state !== RunnerJobState.PENDING) {
+ res.fail({
+ type: ServerErrorCode.RUNNER_JOB_NOT_IN_PENDING_STATE,
+ message: 'This job is not in pending state anymore',
+ status: HttpStatusCode.CONFLICT_409
+ })
+
+ return undefined
+ }
+
+ runnerJob.state = RunnerJobState.PROCESSING
+ runnerJob.processingJobToken = generateRunnerJobToken()
+ runnerJob.startedAt = new Date()
+ runnerJob.runnerId = runner.id
+
+ return runnerJob.save({ transaction })
+ })