Fixed scan runner in response

ref #67
This commit is contained in:
2021-01-07 16:38:41 +01:00
parent 30502ec949
commit e67d1c5697
3 changed files with 10 additions and 9 deletions

View File

@@ -26,7 +26,7 @@ export class ScanController {
@OpenAPI({ description: 'Lists all scans (normal or track) from all runners. <br> This includes the runner\'s group and distance ran.' })
async getAll() {
let responseScans: ResponseScan[] = new Array<ResponseScan>();
const scans = await this.scanRepository.find();
const scans = await this.scanRepository.find({ relations: ['runner'] });
scans.forEach(scan => {
responseScans.push(scan.toResponse());
});
@@ -41,9 +41,9 @@ export class ScanController {
@OnUndefined(ScanNotFoundError)
@OpenAPI({ description: 'Lists all information about the runner whose id got provided.' })
async getOne(@Param('id') id: number) {
let scan = await this.scanRepository.findOne({ id: id })
let scan = await this.scanRepository.findOne({ id: id }, { relations: ['runner'] })
if (!scan) { throw new ScanNotFoundError(); }
return scan;
return scan.toResponse();
}
@Post()
@@ -54,7 +54,7 @@ export class ScanController {
let scan = await createScan.toScan();
scan = await this.scanRepository.save(scan);
console.log(scan);
return (await this.scanRepository.findOne({ id: scan.id })).toResponse();
return (await this.scanRepository.findOne({ id: scan.id }, { relations: ['runner'] })).toResponse();
}
// @Put('/:id')