Added missing getter

This commit is contained in:
Nicolai Ort 2020-12-02 15:46:53 +01:00
parent abf7aaeda3
commit 84dd1fe4a5

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);
}
}