All checks were successful
		
		
	
	continuous-integration/drone/pr Build is passing
				
			ref #132
		
			
				
	
	
		
			78 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			78 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
| import {
 | |
|     IsInt,
 | |
|     IsObject,
 | |
|     IsString
 | |
| } from "class-validator";
 | |
| import { Runner } from '../entities/Runner';
 | |
| import { ResponseObjectType } from '../enums/ResponseObjectType';
 | |
| import { IResponse } from './IResponse';
 | |
| import { ResponseRunnerGroup } from './ResponseRunnerGroup';
 | |
| 
 | |
| /**
 | |
|  * Defines the runner stats response.
 | |
|  * This differs from the normal runner responce.
 | |
| */
 | |
| export class ResponseStatsRunner implements IResponse {
 | |
|     /**
 | |
|     * The responseType.
 | |
|     * This contains the type of class/entity this response contains.
 | |
|     */
 | |
|     responseType: ResponseObjectType = ResponseObjectType.STATSRUNNER;
 | |
| 
 | |
|     /**
 | |
|      * The runner's id.
 | |
|      */
 | |
|     @IsInt()
 | |
|     id: number;
 | |
| 
 | |
|     /**
 | |
|      * The runner's first name.
 | |
|      */
 | |
|     @IsString()
 | |
|     firstname: string;
 | |
| 
 | |
|     /**
 | |
|      * The runner's middle name.
 | |
|      */
 | |
|     @IsString()
 | |
|     middlename?: string;
 | |
| 
 | |
|     /**
 | |
|      * The runner's last name.
 | |
|      */
 | |
|     @IsString()
 | |
|     lastname: string;
 | |
| 
 | |
|     /**
 | |
|      * The runner's currently ran distance in meters.
 | |
|      */
 | |
|     @IsInt()
 | |
|     distance: number;
 | |
| 
 | |
|     /**
 | |
|      * The runner's currently collected donations.
 | |
|      */
 | |
|     @IsInt()
 | |
|     donationAmount: number;
 | |
| 
 | |
|     /**
 | |
|      * The runner's group.
 | |
|      */
 | |
|     @IsObject()
 | |
|     group: ResponseRunnerGroup;
 | |
| 
 | |
|     /**
 | |
|      * Creates a new runner stats response from a runner
 | |
|      * @param runner The runner whoes response shall be generated - the following relations have to be resolved: scans, group, distanceDonations, scans.track
 | |
|      */
 | |
|     public constructor(runner: Runner) {
 | |
|         this.id = runner.id;
 | |
|         this.firstname = runner.firstname;
 | |
|         this.middlename = runner.middlename;
 | |
|         this.lastname = runner.lastname;
 | |
|         this.distance = runner.distance;
 | |
|         this.donationAmount = runner.distanceDonationAmount;
 | |
|         this.group = runner.group.toResponse();
 | |
|     }
 | |
| }
 |