feat(stats): Publish runners by kiosk stat

This commit is contained in:
Nicolai Ort 2025-04-08 21:15:41 +02:00
parent a41758cd9c
commit a6afba93e2
Signed by: niggl
GPG Key ID: 13AFA55AF62F269F
2 changed files with 10 additions and 2 deletions

View File

@ -24,6 +24,7 @@ export class StatsController {
async get() {
const connection = getConnection();
const runnersViaSelfservice = await connection.getRepository(Runner).count({ where: { created_via: "selfservice" } });
const runnersViaKiosk = await connection.getRepository(Runner).count({ where: { created_via: "kiosk" } });
const runners = await connection.getRepository(Runner).count();
const teams = await connection.getRepository(RunnerTeam).count();
const orgs = await connection.getRepository(RunnerOrganization).count();
@ -42,7 +43,7 @@ export class StatsController {
let donations = await connection.getRepository(Donation).find({ relations: ['runner', 'runner.scans', 'runner.scans.track'] });
const donors = await connection.getRepository(Donor).count();
return new ResponseStats(runnersViaSelfservice, runners, teams, orgs, users, scans, donations, distace, donors)
return new ResponseStats(runnersViaSelfservice, runners, teams, orgs, users, scans, donations, distace, donors, runnersViaKiosk)
}
@Get("/runners/distance")

View File

@ -22,6 +22,12 @@ export class ResponseStats implements IResponse {
@IsInt()
runnersViaSelfservice: number;
/**
* The amount of runners registered via kiosk.
*/
@IsInt()
runnersViaKiosk: number;
/**
* The amount of runners registered in the system.
*/
@ -98,7 +104,7 @@ export class ResponseStats implements IResponse {
* @param scans number of scans - no relations have to be resolved.
* @param donations Array containing all donations - the following relations have to be resolved: runner, runner.scans, runner.scans.track
*/
public constructor(runnersViaSelfservice: number, runners: number, teams: number, orgs: number, users: number, scans: number, donations: Donation[], distance: number, donors: number) {
public constructor(runnersViaSelfservice: number, runners: number, teams: number, orgs: number, users: number, scans: number, donations: Donation[], distance: number, donors: number, runnersViaKiosk: number) {
this.runnersViaSelfservice = runnersViaSelfservice;
this.total_runners = runners;
this.total_teams = teams;
@ -111,5 +117,6 @@ export class ResponseStats implements IResponse {
this.average_donation = this.total_donation / this.total_donations
this.total_donors = donors;
this.average_distance = this.total_distance / this.total_runners;
this.runnersViaKiosk = runnersViaKiosk;
}
}