parent
a6bca59ffe
commit
fbdadbef1f
@ -1,9 +1,9 @@
|
|||||||
import { IsBoolean, IsInt, IsOptional, IsPositive } from 'class-validator';
|
import { IsBoolean, IsInt, IsOptional, IsPositive } from 'class-validator';
|
||||||
import { getConnection } from 'typeorm';
|
import { getConnection } from 'typeorm';
|
||||||
import { RunnerNotFoundError } from '../../../errors/RunnerErrors';
|
import { RunnerNotFoundError } from '../../../errors/RunnerErrors';
|
||||||
import { ScanStationNotFoundError } from '../../../errors/ScanStationErrors';
|
import { TrackNotFoundError } from '../../../errors/TrackErrors';
|
||||||
import { Runner } from '../../entities/Runner';
|
import { Runner } from '../../entities/Runner';
|
||||||
import { ScanStation } from '../../entities/ScanStation';
|
import { Track } from '../../entities/Track';
|
||||||
import { TrackScan } from '../../entities/TrackScan';
|
import { TrackScan } from '../../entities/TrackScan';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -38,7 +38,7 @@ export abstract class UpdateTrackScan {
|
|||||||
*/
|
*/
|
||||||
@IsInt()
|
@IsInt()
|
||||||
@IsPositive()
|
@IsPositive()
|
||||||
public station: number;
|
public track: number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update a TrackScan entity based on this.
|
* Update a TrackScan entity based on this.
|
||||||
@ -47,8 +47,7 @@ export abstract class UpdateTrackScan {
|
|||||||
public async update(scan: TrackScan): Promise<TrackScan> {
|
public async update(scan: TrackScan): Promise<TrackScan> {
|
||||||
scan.valid = this.valid;
|
scan.valid = this.valid;
|
||||||
scan.runner = await this.getRunner();
|
scan.runner = await this.getRunner();
|
||||||
scan.station = await this.getStation();
|
scan.track = await this.getTrack();
|
||||||
scan.track = scan.station.track;
|
|
||||||
|
|
||||||
return scan;
|
return scan;
|
||||||
}
|
}
|
||||||
@ -67,11 +66,11 @@ export abstract class UpdateTrackScan {
|
|||||||
/**
|
/**
|
||||||
* Gets a runner based on the runner id provided via this.runner.
|
* Gets a runner based on the runner id provided via this.runner.
|
||||||
*/
|
*/
|
||||||
public async getStation(): Promise<ScanStation> {
|
public async getTrack(): Promise<Track> {
|
||||||
const station = await getConnection().getRepository(ScanStation).findOne({ id: this.station }, { relations: ['track'] });
|
const track = await getConnection().getRepository(Track).findOne({ id: this.track });
|
||||||
if (!station) {
|
if (!track) {
|
||||||
throw new ScanStationNotFoundError();
|
throw new TrackNotFoundError();
|
||||||
}
|
}
|
||||||
return station;
|
return track;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user