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