backend/src/models/responses/ResponseStatsTeam.ts
Nicolai Ort e0fa58da57
All checks were successful
continuous-integration/drone/pr Build is passing
Added some comments
ref #56
2020-12-30 17:27:24 +01:00

56 lines
1.2 KiB
TypeScript

import {
IsInt,
IsObject,
IsString
} from "class-validator";
import { RunnerGroup } from '../entities/RunnerGroup';
import { RunnerTeam } from '../entities/RunnerTeam';
/**
* Defines the team stats response.
* This differs from the normal team responce.
*/
export class ResponseStatsTeam {
/**
* The team's id.
*/
@IsInt()
id: number;
/**
* The team's name.
*/
@IsString()
name: string;
/**
* The teams's currently ran distance in meters.
*/
@IsInt()
distance: number;
/**
* The teams's currently collected donations.
*/
@IsInt()
donationAmount: number;
/**
* The teams's parent group.
*/
@IsObject()
parent: RunnerGroup;
/**
* Creates a new team stats response from a team
* @param team The team whoes response shall be generated - the following relations have to be resolved: runners, runners.scans, runners.distanceDonations, runners.scans.track
*/
public constructor(team: RunnerTeam) {
this.name = team.name;
this.id = team.id;
this.parent = team.parentGroup;
this.distance = team.distance;
this.donationAmount = team.distanceDonationAmount;
}
}