parent
7c3a1b8fff
commit
937a9fad4d
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue