feat(runners): Include collected distance donation amount in runner detail
This commit is contained in:
@@ -27,6 +27,13 @@ export class ResponseRunner extends ResponseParticipant implements IResponse {
|
||||
@IsInt()
|
||||
distance: number;
|
||||
|
||||
/**
|
||||
* The runner's current donation amount based on distance.
|
||||
* Only available for queries for single runners.
|
||||
*/
|
||||
@IsInt()
|
||||
donationAmount: number;
|
||||
|
||||
/**
|
||||
* The runner's group.
|
||||
*/
|
||||
@@ -50,6 +57,10 @@ export class ResponseRunner extends ResponseParticipant implements IResponse {
|
||||
else { this.distance = runner.validScans.reduce((sum, current) => sum + current.distance, 0); }
|
||||
if (runner.group) { this.group = runner.group.toResponse(); }
|
||||
|
||||
if (runner.distanceDonations) {
|
||||
this.donationAmount = runner.distanceDonations.reduce((sum, current) => sum + (current.amountPerDistance * runner.distance / 1000), 0);
|
||||
}
|
||||
|
||||
if (generateSelfServiceLink) {
|
||||
const token = JwtCreator.createSelfService(runner);
|
||||
this.selfserviceLink = `${process.env.SELFSERVICE_URL}/profile/${token}`;
|
||||
|
||||
Reference in New Issue
Block a user