From 6f39ac42dafc2a589bbb2256b0417f3e774ae174 Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Wed, 19 Apr 2023 15:41:43 +0200 Subject: [PATCH] feat(stats): Added donation count and donor count to stats --- src/models/responses/ResponseStats.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/models/responses/ResponseStats.ts b/src/models/responses/ResponseStats.ts index 10669c9..55abd1a 100644 --- a/src/models/responses/ResponseStats.ts +++ b/src/models/responses/ResponseStats.ts @@ -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; } }