@@ -44,4 +44,20 @@ export abstract class RunnerGroup {
 | 
			
		||||
   */
 | 
			
		||||
  @OneToMany(() => Runner, runner => runner.group, { nullable: true })
 | 
			
		||||
  runners: Runner[];
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Returns the total distance ran by this group's runners based on all their valid scans.
 | 
			
		||||
  */
 | 
			
		||||
  @IsInt()
 | 
			
		||||
  public get distance(): number {
 | 
			
		||||
    return this.runners.reduce((sum, current) => sum + current.distance, 0);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Returns the total donations a runner has collected based on his linked donations and distance ran.
 | 
			
		||||
  */
 | 
			
		||||
  @IsInt()
 | 
			
		||||
  public get distanceDonationAmount(): number {
 | 
			
		||||
    return this.runners.reduce((sum, current) => sum + current.distanceDonationAmount, 0);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user