| @@ -29,7 +29,8 @@ export class ResponseRunner extends ResponseParticipant { | ||||
|      */ | ||||
|     public constructor(runner: Runner) { | ||||
|         super(runner); | ||||
|         this.distance = runner.scans.filter(scan => { scan.valid === true }).reduce((sum, current) => sum + current.distance, 0); | ||||
|         if (!runner.scans) { this.distance = 0 } | ||||
|         else { this.distance = runner.scans.filter(scan => { scan.valid === true }).reduce((sum, current) => sum + current.distance, 0); } | ||||
|         this.group = runner.group; | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| import { IsBoolean, IsInt, IsPositive } from "class-validator"; | ||||
| import { IsBoolean, IsInt, IsNotEmpty, IsPositive } from "class-validator"; | ||||
| import { Scan } from '../entities/Scan'; | ||||
| import { ResponseRunner } from './ResponseRunner'; | ||||
|  | ||||
| @@ -16,8 +16,8 @@ export class ResponseScan { | ||||
|      * The scan's associated runner. | ||||
|      * This is important to link ran distances to runners. | ||||
|      */ | ||||
|     // @IsNotEmpty() | ||||
|     runner?: ResponseRunner; | ||||
|     @IsNotEmpty() | ||||
|     runner: ResponseRunner; | ||||
|  | ||||
|     /** | ||||
|      * Is the scan valid (for fraud reasons). | ||||
| @@ -39,7 +39,7 @@ export class ResponseScan { | ||||
|      */ | ||||
|     public constructor(scan: Scan) { | ||||
|         this.id = scan.id; | ||||
|         this.runner = null; | ||||
|         this.runner = scan.runner.toResponse(); | ||||
|         this.distance = scan.distance; | ||||
|         this.valid = scan.valid; | ||||
|     } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user