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) {