add more statistics
All checks were successful
Deploy Backend / docker (ubuntu-latest) (push) Successful in 48s
Deploy Website / docker (ubuntu-latest) (push) Successful in 2m26s

This commit is contained in:
Lee 2024-10-24 14:36:24 +01:00
parent aaee96ad7b
commit 6d0c6aa47f
3 changed files with 27 additions and 0 deletions

@ -1,5 +1,8 @@
import { PlayerModel } from "@ssr/common/model/player"; import { PlayerModel } from "@ssr/common/model/player";
import { AppStatistics } from "@ssr/common/types/backend/app-statistics"; import { AppStatistics } from "@ssr/common/types/backend/app-statistics";
import { ScoreSaberScoreModel } from "@ssr/common/model/score/impl/scoresaber-score";
import { AdditionalScoreDataModel } from "@ssr/common/model/additional-score-data/additional-score-data";
import { BeatSaverMapModel } from "@ssr/common/model/beatsaver/map";
export class AppService { export class AppService {
/** /**
@ -7,9 +10,15 @@ export class AppService {
*/ */
public static async getAppStatistics(): Promise<AppStatistics> { public static async getAppStatistics(): Promise<AppStatistics> {
const trackedPlayers = await PlayerModel.countDocuments(); const trackedPlayers = await PlayerModel.countDocuments();
const trackedScores = await ScoreSaberScoreModel.countDocuments();
const additionalScoresData = await AdditionalScoreDataModel.countDocuments();
const cachedBeatSaverMaps = await BeatSaverMapModel.countDocuments();
return { return {
trackedPlayers, trackedPlayers,
trackedScores,
additionalScoresData,
cachedBeatSaverMaps,
}; };
} }
} }

@ -3,4 +3,19 @@ export type AppStatistics = {
* The total amount of players being tracked. * The total amount of players being tracked.
*/ */
trackedPlayers: number; trackedPlayers: number;
/**
* The total amount of ScoreSaber scores tracked.
*/
trackedScores: number;
/**
* The total amount of additional data for scores being tracked.
*/
additionalScoresData: number;
/**
* The amount of cached BeatSaver maps.
*/
cachedBeatSaverMaps: number;
}; };

@ -25,6 +25,9 @@ export default async function HomePage() {
<div className="flex items-center flex-col"> <div className="flex items-center flex-col">
<p className="font-semibold">Site Statistics</p> <p className="font-semibold">Site Statistics</p>
<Statistic title="Total Tracked Players" value={statistics.trackedPlayers} /> <Statistic title="Total Tracked Players" value={statistics.trackedPlayers} />
<Statistic title="Total Tracked Scores" value={statistics.trackedScores} />
<Statistic title="Total Additional Scores Data" value={statistics.additionalScoresData} />
<Statistic title="Cached BeatSaver Maps" value={statistics.cachedBeatSaverMaps} />
</div> </div>
)} )}