From c0d2781fd0be3802e2f18885eb24c8e485e8ea61 Mon Sep 17 00:00:00 2001 From: Liam Date: Thu, 25 Apr 2024 20:06:06 +0100 Subject: [PATCH] use account name not id --- .../backend/service/ScoreSaberService.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/cc/fascinated/backend/service/ScoreSaberService.java b/src/main/java/cc/fascinated/backend/service/ScoreSaberService.java index dc2c4a9..5353682 100644 --- a/src/main/java/cc/fascinated/backend/service/ScoreSaberService.java +++ b/src/main/java/cc/fascinated/backend/service/ScoreSaberService.java @@ -90,7 +90,7 @@ public class ScoreSaberService extends TextWebSocketHandler { * @return The scores. */ public ScoreSaberScoresPageToken getPageScores(Account account, int page) { - log.info("Fetching scores for account '{}' from page {}.", account.getId(), page); + log.info("Fetching scores for account '{}' from page {}.", account.getName(), page); ScoreSaberScoresPageToken pageToken = WebRequest.getAsEntity(String.format(GET_PLAYER_SCORES_ENDPOINT, account.getId(), "recent", page), ScoreSaberScoresPageToken.class); if (pageToken == null) { // Check if the page doesn't exist. return null; @@ -126,12 +126,12 @@ public class ScoreSaberService extends TextWebSocketHandler { * @param account The account. */ public void updateScores(Account account) { - String id = account.getId(); + String name = account.getName(); // Fetch the scores for the account. - List scores = scoreRepository.getScoresForAccount(id); + List scores = scoreRepository.getScoresForAccount(account.getId()); if (scores.isEmpty()) { - log.warn("Account '{}' has no scores, fetching them.", id); + log.warn("Account '{}' has no scores, fetching them.", name); List scoresPageTokens = this.getScores(account); List newScores = new ArrayList<>(); @@ -139,7 +139,7 @@ public class ScoreSaberService extends TextWebSocketHandler { for (ScoreSaberScoresPageToken page : scoresPageTokens) { for (ScoreSaberPlayerScoreToken scoreToken : page.getPlayerScores()) { - Score score = Score.fromToken(id, scoreToken); + Score score = Score.fromToken(account.getId(), scoreToken); newScores.add(score); scores.add(score); leaderboardToSave.add(Leaderboard.fromToken(scoreToken.getLeaderboard())); @@ -154,12 +154,12 @@ public class ScoreSaberService extends TextWebSocketHandler { } scoreRepository.saveAll(newScores); // Save the player's scores. - log.info("Found {} scores for account '{}'.", newScores.size(), id); + log.info("Found {} scores for account '{}'.", newScores.size(), name); return; } long start = System.currentTimeMillis(); - log.info("Fetching new scores for account '{}'.", id); + log.info("Fetching new scores for account '{}'.", name); int page = 1; // The current page to search for scores. boolean done = false; // Whether we are done fetching scores. @@ -183,7 +183,7 @@ public class ScoreSaberService extends TextWebSocketHandler { saveScore(account, score); } - log.info("Found {} new scores for account '{}'. (took: {}ms)", newScores.size(), id, System.currentTimeMillis() - start); + log.info("Found {} new scores for account '{}'. (took: {}ms)", newScores.size(), name, System.currentTimeMillis() - start); } /**