diff --git a/apps/api/src/runs/run.entity.ts b/apps/api/src/runs/run.entity.ts index 6e9e4ca..8904060 100644 --- a/apps/api/src/runs/run.entity.ts +++ b/apps/api/src/runs/run.entity.ts @@ -101,6 +101,10 @@ export class RunEntity implements Run { throw new Error(`Run has been already closed!`); } + if (this.tasks.length === 0) { + this.complete(); + } + this.closed = true; } } diff --git a/apps/api/src/runs/runs.service.ts b/apps/api/src/runs/runs.service.ts index 308a26a..847945e 100644 --- a/apps/api/src/runs/runs.service.ts +++ b/apps/api/src/runs/runs.service.ts @@ -54,7 +54,10 @@ export class RunsService { } async close(id: number): Promise { - const run = await this.runsRepository.findOneBy({ id: id }); + const run = await this.runsRepository.findOne({ + where: { id: id }, + relations: { tasks: true }, + }); run.close(); return this.runsRepository.save(run); }