From 4cc48412f7c431aa96eda27be56537dbd85a10a2 Mon Sep 17 00:00:00 2001 From: Liam Date: Fri, 5 Jul 2024 23:02:27 +0100 Subject: [PATCH] don't log as much when getting scores for SS --- .../java/cc/fascinated/bat/service/ScoreSaberService.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/cc/fascinated/bat/service/ScoreSaberService.java b/src/main/java/cc/fascinated/bat/service/ScoreSaberService.java index 847a2c2..4c7245c 100644 --- a/src/main/java/cc/fascinated/bat/service/ScoreSaberService.java +++ b/src/main/java/cc/fascinated/bat/service/ScoreSaberService.java @@ -104,13 +104,15 @@ public class ScoreSaberService extends TextWebSocketHandler { public CachedPage getPageScores(ScoreSaberProfile profile, int page) { String key = profile.getAccountId() + "." + page; // Check if the page is cached, but don't cache the first page as it's the most likely to change. + CachedPage cachedPage = cachedScorePages.get(key); if (cachedScorePages.containsKey(key) && page != 1) { - CachedPage cachedPage = cachedScorePages.get(key); cachedPage.setCached(true); return cachedPage; } - log.info("Fetching scores for account '{}' from page {}.", profile.getAccountId(), page); + if (page == 1 || page % 5 == 0 || (cachedPage != null && cachedPage.getPage().getMetadata().getTotal() == page)) { + log.info("Fetching scores for account '{}' from page {}.", profile.getAccountId(), page); + } ScoreSaberScoresPageToken pageToken = WebRequest.getAsEntity(String.format(GET_PLAYER_SCORES_ENDPOINT, profile.getAccountId(), "recent", page), ScoreSaberScoresPageToken.class); if (pageToken == null) { // Check if the page doesn't exist. return null; @@ -119,7 +121,7 @@ public class ScoreSaberService extends TextWebSocketHandler { pageToken.setPlayerScores(Arrays.stream(pageToken.getPlayerScores()) .sorted((a, b) -> DateUtils.getDateFromString(b.getScore().getTimeSet()).compareTo(DateUtils.getDateFromString(a.getScore().getTimeSet()))) .toArray(ScoreSaberPlayerScoreToken[]::new)); - CachedPage cachedPage = new CachedPage(pageToken, false); + cachedPage = new CachedPage(pageToken, false); cachedScorePages.put(key, cachedPage); return cachedPage; }