Added average donation per distance to stats
This commit is contained in:
parent
42c23a5883
commit
fe59e3a557
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue