Added comments✏

ref #150
This commit is contained in:
Nicolai Ort 2021-03-17 19:21:29 +01:00
parent 7c3a1b8fff
commit 937a9fad4d
1 changed files with 16 additions and 0 deletions

View File

@ -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<RunnerCard> {
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<ScanStation> {
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<TrackScan> {
const scans = await getConnection().getRepository(TrackScan).find({ where: { runner: scan.runner, valid: true }, relations: ["track"] });
if (scans.length == 0) {