Now with even more inheritance and fancy stuff: RunnerResponses now get their information from participant responses
ref #13
This commit is contained in:
parent
7b08489533
commit
b480912bd8
|
@ -0,0 +1,61 @@
|
|||
import {
|
||||
IsInt,
|
||||
|
||||
|
||||
|
||||
IsString
|
||||
} from "class-validator";
|
||||
import { Participant } from '../entities/Participant';
|
||||
|
||||
/**
|
||||
* Defines a participant response.
|
||||
*/
|
||||
export abstract class ResponseParticipant {
|
||||
/**
|
||||
* Autogenerated unique id (primary key).
|
||||
*/
|
||||
@IsInt()
|
||||
id: number;;
|
||||
|
||||
/**
|
||||
* The participant's first name.
|
||||
*/
|
||||
@IsString()
|
||||
firstname: string;
|
||||
|
||||
/**
|
||||
* The participant's middle name.
|
||||
* Optional.
|
||||
*/
|
||||
@IsString()
|
||||
middlename?: string;
|
||||
|
||||
/**
|
||||
* The participant's last name.
|
||||
*/
|
||||
@IsString()
|
||||
lastname: string;
|
||||
|
||||
/**
|
||||
* The participant's phone number.
|
||||
* Optional.
|
||||
*/
|
||||
@IsString()
|
||||
phone?: string;
|
||||
|
||||
/**
|
||||
* The participant's e-mail address.
|
||||
* Optional.
|
||||
*/
|
||||
@IsString()
|
||||
email?: string;
|
||||
|
||||
public constructor(participant: Participant) {
|
||||
this.id = participant.id;
|
||||
this.firstname = participant.firstname;
|
||||
this.middlename = participant.middlename;
|
||||
this.lastname = participant.lastname;
|
||||
this.phone = participant.phone;
|
||||
this.email = participant.email;
|
||||
}
|
||||
}
|
|
@ -1,55 +1,15 @@
|
|||
import {
|
||||
IsInt,
|
||||
|
||||
IsObject,
|
||||
|
||||
IsString
|
||||
IsObject
|
||||
} from "class-validator";
|
||||
import { Runner } from '../entities/Runner';
|
||||
import { RunnerGroup } from '../entities/RunnerGroup';
|
||||
import { ResponseParticipant } from './ResponseParticipant';
|
||||
|
||||
/**
|
||||
* Defines a track of given length.
|
||||
* Defines RunnerTeam's response class.
|
||||
*/
|
||||
export class ResponseRunner {
|
||||
/**
|
||||
* Autogenerated unique id (primary key).
|
||||
*/
|
||||
@IsInt()
|
||||
id: number;;
|
||||
|
||||
/**
|
||||
* The runner's first name.
|
||||
*/
|
||||
@IsString()
|
||||
firstname: string;
|
||||
|
||||
/**
|
||||
* The runner's middle name.
|
||||
* Optional.
|
||||
*/
|
||||
@IsString()
|
||||
middlename?: string;
|
||||
|
||||
/**
|
||||
* The runner's last name.
|
||||
*/
|
||||
@IsString()
|
||||
lastname: string;
|
||||
|
||||
/**
|
||||
* The runner's phone number.
|
||||
* Optional.
|
||||
*/
|
||||
@IsString()
|
||||
phone?: string;
|
||||
|
||||
/**
|
||||
* The runner's e-mail address.
|
||||
* Optional.
|
||||
*/
|
||||
@IsString()
|
||||
email?: string;
|
||||
export class ResponseRunner extends ResponseParticipant {
|
||||
|
||||
/**
|
||||
* The runner's currently ran distance in meters.
|
||||
|
@ -64,14 +24,8 @@ export class ResponseRunner {
|
|||
@IsObject()
|
||||
group: RunnerGroup;
|
||||
|
||||
|
||||
public constructor(runner: Runner) {
|
||||
this.id = runner.id;
|
||||
this.firstname = runner.firstname;
|
||||
this.middlename = runner.middlename;
|
||||
this.lastname = runner.lastname;
|
||||
this.phone = runner.phone;
|
||||
this.email = runner.email;
|
||||
super(runner);
|
||||
this.distance = runner.scans.reduce((sum, current) => sum + current.distance, 0);
|
||||
this.group = runner.group;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue