From bded9969fe32310d23e88eb6a5f4cb8b0e86a829 Mon Sep 17 00:00:00 2001 From: Liam Date: Sun, 20 Oct 2024 19:34:54 +0100 Subject: [PATCH] track total scores and total ranked scores --- projects/backend/src/service/player.service.ts | 10 +++++++++- projects/common/src/player/impl/scoresaber-player.ts | 6 ++++++ projects/common/src/player/player-history.ts | 10 ++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/projects/backend/src/service/player.service.ts b/projects/backend/src/service/player.service.ts index 0c2bb56..bb3a7fb 100644 --- a/projects/backend/src/service/player.service.ts +++ b/projects/backend/src/service/player.service.ts @@ -140,13 +140,21 @@ export class PlayerService { if (history == undefined) { history = {}; // Initialize if history is not found } + + const scoreStats = player.scoreStats; + // Set the history data history.pp = player.pp; history.countryRank = player.countryRank; history.rank = player.rank; history.accuracy = { - averageRankedAccuracy: player.scoreStats.averageRankedAccuracy, + averageRankedAccuracy: scoreStats.averageRankedAccuracy, }; + history.scores = { + totalScores: scoreStats.totalPlayCount, + totalRankedScores: scoreStats.rankedPlayCount, + }; + foundPlayer.setStatisticHistory(dateToday, history); foundPlayer.sortStatisticHistory(); foundPlayer.lastTracked = new Date(); diff --git a/projects/common/src/player/impl/scoresaber-player.ts b/projects/common/src/player/impl/scoresaber-player.ts index af1cfa5..712c146 100644 --- a/projects/common/src/player/impl/scoresaber-player.ts +++ b/projects/common/src/player/impl/scoresaber-player.ts @@ -114,6 +114,8 @@ export async function getScoreSaberPlayerFromToken( scores: { rankedScores: 0, unrankedScores: 0, + totalScores: 0, + totalRankedScores: 0, }, }, ...history[todayDate], @@ -152,6 +154,10 @@ export async function getScoreSaberPlayerFromToken( statisticHistory[dateKey] = { ...statisticHistory[dateKey], rank: rank, + scores: { + totalScores: token.scoreStats.totalPlayCount, + totalRankedScores: token.scoreStats.rankedPlayCount, + }, }; } } diff --git a/projects/common/src/player/player-history.ts b/projects/common/src/player/player-history.ts index a08cc1f..b928166 100644 --- a/projects/common/src/player/player-history.ts +++ b/projects/common/src/player/player-history.ts @@ -27,6 +27,16 @@ export interface PlayerHistory { * The amount of unranked scores set. */ unrankedScores?: number; + + /** + * The total amount of ranked scores + */ + totalRankedScores?: number; + + /** + * The total amount of scores + */ + totalScores?: number; }; /**