feat(stats): Publish runners by kiosk stat
This commit is contained in:
parent
a41758cd9c
commit
a6afba93e2
@ -24,6 +24,7 @@ export class StatsController {
|
|||||||
async get() {
|
async get() {
|
||||||
const connection = getConnection();
|
const connection = getConnection();
|
||||||
const runnersViaSelfservice = await connection.getRepository(Runner).count({ where: { created_via: "selfservice" } });
|
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 runners = await connection.getRepository(Runner).count();
|
||||||
const teams = await connection.getRepository(RunnerTeam).count();
|
const teams = await connection.getRepository(RunnerTeam).count();
|
||||||
const orgs = await connection.getRepository(RunnerOrganization).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'] });
|
let donations = await connection.getRepository(Donation).find({ relations: ['runner', 'runner.scans', 'runner.scans.track'] });
|
||||||
const donors = await connection.getRepository(Donor).count();
|
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")
|
@Get("/runners/distance")
|
||||||
|
@ -22,6 +22,12 @@ export class ResponseStats implements IResponse {
|
|||||||
@IsInt()
|
@IsInt()
|
||||||
runnersViaSelfservice: number;
|
runnersViaSelfservice: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The amount of runners registered via kiosk.
|
||||||
|
*/
|
||||||
|
@IsInt()
|
||||||
|
runnersViaKiosk: number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The amount of runners registered in the system.
|
* 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 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
|
* @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.runnersViaSelfservice = runnersViaSelfservice;
|
||||||
this.total_runners = runners;
|
this.total_runners = runners;
|
||||||
this.total_teams = teams;
|
this.total_teams = teams;
|
||||||
@ -111,5 +117,6 @@ export class ResponseStats implements IResponse {
|
|||||||
this.average_donation = this.total_donation / this.total_donations
|
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;
|
||||||
|
this.runnersViaKiosk = runnersViaKiosk;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user