feat(runners): Include collected distance donation amount in runner detail

This commit is contained in:
2025-05-01 16:02:28 +02:00
parent f4747c51de
commit 4494afc64b
2 changed files with 12 additions and 1 deletions

View File

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