Added average donation per distance to stats
This commit is contained in:
		@@ -76,6 +76,12 @@ export class ResponseStats implements IResponse {
 | 
				
			|||||||
    @IsInt()
 | 
					    @IsInt()
 | 
				
			||||||
    average_distance: number;
 | 
					    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.
 | 
					     * 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
 | 
					     * @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_distance = distance;
 | 
				
			||||||
        this.total_donation = donations.reduce((sum, current) => sum + current.amount, 0);
 | 
					        this.total_donation = donations.reduce((sum, current) => sum + current.amount, 0);
 | 
				
			||||||
        this.total_donations = donations.length;
 | 
					        this.total_donations = donations.length;
 | 
				
			||||||
 | 
					        this.average_donation = this.total_donation / this.total_donations
 | 
				
			||||||
        this.total_donors = donors;
 | 
					        this.total_donors = donors;
 | 
				
			||||||
        this.average_distance = this.total_distance / this.total_runners;
 | 
					        this.average_distance = this.total_distance / this.total_runners;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user