feature/11-new_classes #15

Merged
niggl merged 55 commits from feature/11-new_classes into dev 2020-12-02 17:48:19 +00:00
Showing only changes of commit 84dd1fe4a5 - Show all commits

View File

@ -1,5 +1,5 @@
import { Entity, Column, OneToMany, ManyToOne } from "typeorm";
import { IsNotEmpty,} from "class-validator";
import { IsInt, IsNotEmpty,} from "class-validator";
import { Participant } from "./Participant";
import { RunnerGroup } from "./RunnerGroup";
import { DistanceDonation } from "./DistanceDonation";
@ -36,4 +36,10 @@ export class Runner extends Participant {
*/
@OneToMany(() => Scan, scan => scan.runner)
scans: Scan[];
@IsInt()
public get distance() : number {
return this.scans.filter(scan => scan.valid === true).reduce((sum, current) => sum + current.distance, 0);
}
}