use account name not id
All checks were successful
Deploy App / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Successful in 1m19s

This commit is contained in:
Lee 2024-04-25 20:06:06 +01:00
parent e7ee0ef4af
commit c0d2781fd0

@ -90,7 +90,7 @@ public class ScoreSaberService extends TextWebSocketHandler {
* @return The scores. * @return The scores.
*/ */
public ScoreSaberScoresPageToken getPageScores(Account account, int page) { 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); 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. if (pageToken == null) { // Check if the page doesn't exist.
return null; return null;
@ -126,12 +126,12 @@ public class ScoreSaberService extends TextWebSocketHandler {
* @param account The account. * @param account The account.
*/ */
public void updateScores(Account account) { public void updateScores(Account account) {
String id = account.getId(); String name = account.getName();
// Fetch the scores for the account. // Fetch the scores for the account.
List<Score> scores = scoreRepository.getScoresForAccount(id); List<Score> scores = scoreRepository.getScoresForAccount(account.getId());
if (scores.isEmpty()) { if (scores.isEmpty()) {
log.warn("Account '{}' has no scores, fetching them.", id); log.warn("Account '{}' has no scores, fetching them.", name);
List<ScoreSaberScoresPageToken> scoresPageTokens = this.getScores(account); List<ScoreSaberScoresPageToken> scoresPageTokens = this.getScores(account);
List<Score> newScores = new ArrayList<>(); List<Score> newScores = new ArrayList<>();
@ -139,7 +139,7 @@ public class ScoreSaberService extends TextWebSocketHandler {
for (ScoreSaberScoresPageToken page : scoresPageTokens) { for (ScoreSaberScoresPageToken page : scoresPageTokens) {
for (ScoreSaberPlayerScoreToken scoreToken : page.getPlayerScores()) { for (ScoreSaberPlayerScoreToken scoreToken : page.getPlayerScores()) {
Score score = Score.fromToken(id, scoreToken); Score score = Score.fromToken(account.getId(), scoreToken);
newScores.add(score); newScores.add(score);
scores.add(score); scores.add(score);
leaderboardToSave.add(Leaderboard.fromToken(scoreToken.getLeaderboard())); leaderboardToSave.add(Leaderboard.fromToken(scoreToken.getLeaderboard()));
@ -154,12 +154,12 @@ public class ScoreSaberService extends TextWebSocketHandler {
} }
scoreRepository.saveAll(newScores); // Save the player's scores. 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; return;
} }
long start = System.currentTimeMillis(); 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. int page = 1; // The current page to search for scores.
boolean done = false; // Whether we are done fetching scores. boolean done = false; // Whether we are done fetching scores.
@ -183,7 +183,7 @@ public class ScoreSaberService extends TextWebSocketHandler {
saveScore(account, score); 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);
} }
/** /**