Faster stats (not including donations)
This commit is contained in:
@@ -2,11 +2,6 @@ import {
|
||||
IsInt
|
||||
} from "class-validator";
|
||||
import { Donation } from '../entities/Donation';
|
||||
import { Runner } from '../entities/Runner';
|
||||
import { RunnerOrganization } from '../entities/RunnerOrganization';
|
||||
import { RunnerTeam } from '../entities/RunnerTeam';
|
||||
import { Scan } from '../entities/Scan';
|
||||
import { User } from '../entities/User';
|
||||
import { ResponseObjectType } from '../enums/ResponseObjectType';
|
||||
import { IResponse } from './IResponse';
|
||||
|
||||
@@ -78,13 +73,13 @@ export class ResponseStats implements IResponse {
|
||||
* @param scans Array containing all scans - no relations have to be resolved.
|
||||
* @param donations Array containing all donations - the following relations have to be resolved: runner, runner.scans, runner.scans.track
|
||||
*/
|
||||
public constructor(runners: Runner[], teams: RunnerTeam[], orgs: RunnerOrganization[], users: User[], scans: Scan[], donations: Donation[]) {
|
||||
this.total_runners = runners.length;
|
||||
this.total_teams = teams.length;
|
||||
this.total_orgs = orgs.length;
|
||||
this.total_users = users.length;
|
||||
this.total_scans = scans.filter(scan => { scan.valid === true }).length;
|
||||
this.total_distance = runners.reduce((sum, current) => sum + current.distance, 0);
|
||||
public constructor(runners: number, teams: number, orgs: number, users: number, scans: number, donations: Donation[], distance: number) {
|
||||
this.total_runners = runners;
|
||||
this.total_teams = teams;
|
||||
this.total_orgs = orgs;
|
||||
this.total_users = users;
|
||||
this.total_scans = scans;
|
||||
this.total_distance = distance;
|
||||
this.total_donation = donations.reduce((sum, current) => sum + current.amount, 0);
|
||||
this.average_distance = this.total_distance / this.total_runners;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user