From 289f9e219692789f86c631f52c67b578216acb48 Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Wed, 17 Mar 2021 19:21:29 +0100 Subject: [PATCH] =?UTF-8?q?Added=20comments=E2=9C=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ref #160 --- src/models/actions/create/CreateTrackScan.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/models/actions/create/CreateTrackScan.ts b/src/models/actions/create/CreateTrackScan.ts index 0ad4d73..62eca4c 100644 --- a/src/models/actions/create/CreateTrackScan.ts +++ b/src/models/actions/create/CreateTrackScan.ts @@ -49,6 +49,10 @@ export class CreateTrackScan { return newScan; } + /** + * Get's a runnerCard entity via the provided id. + * @returns The runnerCard whom's id you provided. + */ public async getCard(): Promise { const track = await getConnection().getRepository(RunnerCard).findOne({ id: this.card }, { relations: ["runner"] }); if (!track) { @@ -57,7 +61,14 @@ export class CreateTrackScan { return track; } + /** + * Get's a scanstation entity via the provided id. + * @returns The scanstation whom's id you provided. + */ public async getStation(): Promise { + if (!this.station) { + throw new NotAcceptableError("You are missing the station's id!") + } const station = await getConnection().getRepository(ScanStation).findOne({ id: this.station }, { relations: ["track"] }); if (!station) { throw new ScanStationNotFoundError(); @@ -65,6 +76,11 @@ export class CreateTrackScan { return station; } + /** + * Validates the scan and sets it's lap time; + * @param scan The scan you want to validate + * @returns The validated scan with it's laptime set. + */ public async validateScan(scan: TrackScan): Promise { const scans = await getConnection().getRepository(TrackScan).find({ where: { runner: scan.runner, valid: true }, relations: ["track"] }); if (scans.length == 0) {