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; }