don't log as much when getting scores for SS
All checks were successful
Deploy to Dokku / docker (ubuntu-latest) (push) Successful in 56s

This commit is contained in:
Lee 2024-07-05 23:02:27 +01:00
parent ccdeebdc1c
commit 4cc48412f7

@ -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.
if (cachedScorePages.containsKey(key) && page != 1) {
CachedPage cachedPage = cachedScorePages.get(key);
if (cachedScorePages.containsKey(key) && page != 1) {
cachedPage.setCached(true);
return cachedPage;
}
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;
}