parent
a82fc0fb9e
commit
b5f3dec93b
|
@ -56,14 +56,21 @@ export class RunnerController {
|
|||
@ResponseSchema(ResponseScan, { isArray: true })
|
||||
@ResponseSchema(ResponseTrackScan, { isArray: true })
|
||||
@ResponseSchema(RunnerNotFoundError, { statusCode: 404 })
|
||||
@OpenAPI({ description: 'Lists all scans of the runner whose id got provided.' })
|
||||
async getScans(@Param('id') id: number) {
|
||||
@OpenAPI({ description: 'Lists all scans of the runner whose id got provided. <br> If you only want the valid scans just add the ?onlyValid=true query param.' })
|
||||
async getScans(@Param('id') id: number, onlyValid?: boolean) {
|
||||
let responseScans: ResponseScan[] = new Array<ResponseScan>();
|
||||
let runner = await this.runnerRepository.findOne({ id: id }, { relations: ['scans', 'scans.track', 'scans.station', 'scans.runner'] })
|
||||
if (!runner) { throw new RunnerNotFoundError(); }
|
||||
|
||||
for (let scan of runner.scans) {
|
||||
responseScans.push(scan.toResponse());
|
||||
if (!onlyValid) {
|
||||
for (let scan of runner.scans) {
|
||||
responseScans.push(scan.toResponse());
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (let scan of runner.validScans) {
|
||||
responseScans.push(scan.toResponse());
|
||||
}
|
||||
}
|
||||
|
||||
return responseScans;
|
||||
|
|
Loading…
Reference in New Issue