Added average donation per distance to stats

This commit is contained in:
Nicolai Ort 2023-04-19 15:46:50 +02:00
parent 42c23a5883
commit fe59e3a557
Signed by: niggl
GPG Key ID: 13AFA55AF62F269F
1 changed files with 7 additions and 0 deletions

View File

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