Get all scans speed improvement
This commit is contained in:
parent
3b3e68900b
commit
23fa78eb9d
|
@ -1,7 +1,7 @@
|
||||||
import { Request } from "express";
|
import { Request } from "express";
|
||||||
import { Authorized, Body, Delete, Get, JsonController, OnUndefined, Param, Post, Put, QueryParam, Req, UseBefore } from 'routing-controllers';
|
import { Authorized, Body, Delete, Get, JsonController, OnUndefined, Param, Post, Put, QueryParam, Req, UseBefore } from 'routing-controllers';
|
||||||
import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi';
|
import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi';
|
||||||
import { getConnectionManager, Repository } from 'typeorm';
|
import { Repository, getConnectionManager } from 'typeorm';
|
||||||
import { RunnerNotFoundError } from '../errors/RunnerErrors';
|
import { RunnerNotFoundError } from '../errors/RunnerErrors';
|
||||||
import { ScanIdsNotMatchingError, ScanNotFoundError } from '../errors/ScanErrors';
|
import { ScanIdsNotMatchingError, ScanNotFoundError } from '../errors/ScanErrors';
|
||||||
import { ScanStationNotFoundError } from '../errors/ScanStationErrors';
|
import { ScanStationNotFoundError } from '../errors/ScanStationErrors';
|
||||||
|
@ -36,7 +36,7 @@ export class ScanController {
|
||||||
@OpenAPI({ description: 'Lists all scans (normal or track) from all runners. <br> This includes the scan\'s runner\'s distance ran.' })
|
@OpenAPI({ description: 'Lists all scans (normal or track) from all runners. <br> This includes the scan\'s runner\'s distance ran.' })
|
||||||
async getAll() {
|
async getAll() {
|
||||||
let responseScans: ResponseScan[] = new Array<ResponseScan>();
|
let responseScans: ResponseScan[] = new Array<ResponseScan>();
|
||||||
const scans = await this.scanRepository.find({ relations: ['runner', 'track', 'runner.scans', 'runner.group', 'runner.scans.track', 'card', 'station'] });
|
const scans = await this.scanRepository.find({ relations: ['runner', 'track', 'runner.group', 'card', 'station'] });
|
||||||
scans.forEach(scan => {
|
scans.forEach(scan => {
|
||||||
responseScans.push(scan.toResponse());
|
responseScans.push(scan.toResponse());
|
||||||
});
|
});
|
||||||
|
@ -51,7 +51,7 @@ export class ScanController {
|
||||||
@OnUndefined(ScanNotFoundError)
|
@OnUndefined(ScanNotFoundError)
|
||||||
@OpenAPI({ description: 'Lists all information about the scan whose id got provided. This includes the scan\'s runner\'s distance ran.' })
|
@OpenAPI({ description: 'Lists all information about the scan whose id got provided. This includes the scan\'s runner\'s distance ran.' })
|
||||||
async getOne(@Param('id') id: number) {
|
async getOne(@Param('id') id: number) {
|
||||||
let scan = await this.scanRepository.findOne({ id: id }, { relations: ['runner', 'track', 'runner.scans', 'runner.group', 'runner.scans.track', 'card', 'station'] })
|
let scan = await this.scanRepository.findOne({ id: id }, { relations: ['runner', 'track', 'runner.group', 'card', 'station'] })
|
||||||
if (!scan) { throw new ScanNotFoundError(); }
|
if (!scan) { throw new ScanNotFoundError(); }
|
||||||
return scan.toResponse();
|
return scan.toResponse();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue