Skip to content

Commit

Permalink
fix(api): automatically complete run when no tasks
Browse files Browse the repository at this point in the history
closes #70
  • Loading branch information
mathpaquette committed Apr 29, 2023
1 parent 5a7277b commit 70e691f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions apps/api/src/runs/run.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
5 changes: 4 additions & 1 deletion apps/api/src/runs/runs.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ export class RunsService {
}

async close(id: number): Promise<RunEntity> {
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);
}
Expand Down

0 comments on commit 70e691f

Please sign in to comment.