Added min laptime to StatsRunner

ref #190
This commit is contained in:
Nicolai Ort 2021-04-06 08:14:02 +02:00
parent cb71fcd13b
commit 51daf969cf
1 changed files with 12 additions and 1 deletions

View File

@ -1,6 +1,7 @@
import { import {
IsInt, IsInt,
IsObject, IsObject,
IsOptional,
IsString IsString
} from "class-validator"; } from "class-validator";
import { Runner } from '../entities/Runner'; import { Runner } from '../entities/Runner';
@ -55,6 +56,13 @@ export class ResponseStatsRunner implements IResponse {
@IsInt() @IsInt()
donationAmount: number; donationAmount: number;
/**
* The runner's fastest laptime in seconds.
*/
@IsInt()
@IsOptional()
minLaptime?: number;
/** /**
* The runner's group. * The runner's group.
*/ */
@ -65,13 +73,16 @@ export class ResponseStatsRunner implements IResponse {
* Creates a new runner stats response from a runner * Creates a new runner stats response from a runner
* @param runner The runner whoes response shall be generated - the following relations have to be resolved: scans, group, distanceDonations, scans.track * @param runner The runner whoes response shall be generated - the following relations have to be resolved: scans, group, distanceDonations, scans.track
*/ */
public constructor(runner: Runner) { public constructor(runner: Runner, laptime?: number) {
this.id = runner.id; this.id = runner.id;
this.firstname = runner.firstname; this.firstname = runner.firstname;
this.middlename = runner.middlename; this.middlename = runner.middlename;
this.lastname = runner.lastname; this.lastname = runner.lastname;
this.distance = runner.distance; this.distance = runner.distance;
this.donationAmount = runner.distanceDonationAmount; this.donationAmount = runner.distanceDonationAmount;
if (laptime) {
this.minLaptime = laptime;
}
this.group = runner.group.toResponse(); this.group = runner.group.toResponse();
} }
} }