@@ -1,9 +1,9 @@
|
||||
import { Entity, Column, OneToMany, ManyToOne, ChildEntity } from "typeorm";
|
||||
import { IsInt, IsNotEmpty, } from "class-validator";
|
||||
import { Participant } from "./Participant";
|
||||
import { RunnerGroup } from "./RunnerGroup";
|
||||
import { IsInt, IsNotEmpty } from "class-validator";
|
||||
import { ChildEntity, getConnectionManager, ManyToOne, OneToMany } from "typeorm";
|
||||
import { DistanceDonation } from "./DistanceDonation";
|
||||
import { Participant } from "./Participant";
|
||||
import { RunnerCard } from "./RunnerCard";
|
||||
import { RunnerGroup } from "./RunnerGroup";
|
||||
import { Scan } from "./Scan";
|
||||
|
||||
/**
|
||||
@@ -38,7 +38,11 @@ export class Runner extends Participant {
|
||||
|
||||
@IsInt()
|
||||
public get distance(): number {
|
||||
return this.scans.filter(scan => scan.valid === true).reduce((sum, current) => sum + current.distance, 0);
|
||||
getConnectionManager().get().getRepository(Scan).find({ runner: this })
|
||||
.then(myScans => {
|
||||
return myScans.reduce((sum, current) => sum + current.distance, 0);
|
||||
})
|
||||
.catch(err => { throw err })
|
||||
.finally(do => { return -1; });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user