feat(stats): Added donation count and donor count to stats
This commit is contained in:
parent
301f334674
commit
6f39ac42da
|
@ -58,6 +58,18 @@ export class ResponseStats implements IResponse {
|
|||
@IsInt()
|
||||
total_donation: number;
|
||||
|
||||
/**
|
||||
* The total donation count.
|
||||
*/
|
||||
@IsInt()
|
||||
total_donations: number;
|
||||
|
||||
/**
|
||||
* The total donor count.
|
||||
*/
|
||||
@IsInt()
|
||||
total_donors: number;
|
||||
|
||||
/**
|
||||
* The average distance ran per runner.
|
||||
*/
|
||||
|
@ -73,7 +85,7 @@ 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: number, teams: number, orgs: number, users: number, scans: number, donations: Donation[], distance: number) {
|
||||
public constructor(runners: number, teams: number, orgs: number, users: number, scans: number, donations: Donation[], distance: number, donors: number) {
|
||||
this.total_runners = runners;
|
||||
this.total_teams = teams;
|
||||
this.total_orgs = orgs;
|
||||
|
@ -81,6 +93,8 @@ export class ResponseStats implements IResponse {
|
|||
this.total_scans = scans;
|
||||
this.total_distance = distance;
|
||||
this.total_donation = donations.reduce((sum, current) => sum + current.amount, 0);
|
||||
this.total_donations = donations.length;
|
||||
this.total_donors = donors;
|
||||
this.average_distance = this.total_distance / this.total_runners;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue