From fe59e3a557903cf555d4c50098e935c49ca1fac4 Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Wed, 19 Apr 2023 15:46:50 +0200 Subject: [PATCH] Added average donation per distance to stats --- src/models/responses/ResponseStats.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/models/responses/ResponseStats.ts b/src/models/responses/ResponseStats.ts index 55abd1a..e5a7e6e 100644 --- a/src/models/responses/ResponseStats.ts +++ b/src/models/responses/ResponseStats.ts @@ -76,6 +76,12 @@ export class ResponseStats implements IResponse { @IsInt() average_distance: number; + /** + * The average donation per distance. + */ + @IsInt() + average_donation: number; + /** * Creates a new stats response containing some basic statistics for a dashboard or public display. * @param runners Array containing all runners - the following relations have to be resolved: scans, scans.track @@ -94,6 +100,7 @@ export class ResponseStats implements IResponse { this.total_distance = distance; this.total_donation = donations.reduce((sum, current) => sum + current.amount, 0); this.total_donations = donations.length; + this.average_donation = this.total_donation / this.total_donations this.total_donors = donors; this.average_distance = this.total_distance / this.total_runners; }