36 lines
879 B
TypeScript
36 lines
879 B
TypeScript
import {
|
|
IsInt,
|
|
IsObject
|
|
} from "class-validator";
|
|
import { Runner } from '../entities/Runner';
|
|
import { RunnerGroup } from '../entities/RunnerGroup';
|
|
import { ResponseParticipant } from './ResponseParticipant';
|
|
|
|
/**
|
|
* Defines the runner response.
|
|
*/
|
|
export class ResponseRunner extends ResponseParticipant {
|
|
|
|
/**
|
|
* The runner's currently ran distance in meters.
|
|
*/
|
|
@IsInt()
|
|
distance: number;
|
|
|
|
/**
|
|
* The runner's group.
|
|
*/
|
|
@IsObject()
|
|
group: RunnerGroup;
|
|
|
|
/**
|
|
* Creates a ResponseRunner object from a runner.
|
|
* @param runner The user the response shall be build for.
|
|
*/
|
|
public constructor(runner: Runner) {
|
|
super(runner);
|
|
this.distance = runner.scans.filter(scan => { scan.valid === true }).reduce((sum, current) => sum + current.distance, 0);
|
|
this.group = runner.group;
|
|
}
|
|
}
|