From 84eb8a4b944b6c5ec946ee8696112dfbcf7e94f5 Mon Sep 17 00:00:00 2001 From: Liam Date: Mon, 5 Aug 2024 04:25:34 +0100 Subject: [PATCH] api: don't fetch all data when tracking player metrics --- .../cc/fascinated/platform/impl/ScoreSaberPlatform.java | 4 ++-- .../main/java/cc/fascinated/repository/UserRepository.java | 4 ++-- API/src/main/java/cc/fascinated/services/UserService.java | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/API/src/main/java/cc/fascinated/platform/impl/ScoreSaberPlatform.java b/API/src/main/java/cc/fascinated/platform/impl/ScoreSaberPlatform.java index 7a11ba4..f52c784 100644 --- a/API/src/main/java/cc/fascinated/platform/impl/ScoreSaberPlatform.java +++ b/API/src/main/java/cc/fascinated/platform/impl/ScoreSaberPlatform.java @@ -145,10 +145,10 @@ public class ScoreSaberPlatform extends Platform { @Override public void trackPlayerMetrics() { Date date = DateUtils.getMidnightToday(); - for (User user : this.userService.getUsers(false)) { + for (User user : this.userService.getUsers(true)) { HistoryPoint history = user.getHistory().getHistoryForDate(date); if (user.isLinkedAccount()) { // Check if the user has linked their account - ScoreSaberAccountToken account = scoreSaberService.getAccount(user); // Get the account from the ScoreSaber API + ScoreSaberAccountToken account = this.scoreSaberService.getAccount(user); // Get the account from the ScoreSaber API history.setPp(account.getPp()); history.setRank(account.getRank()); history.setCountryRank(account.getCountryRank()); diff --git a/API/src/main/java/cc/fascinated/repository/UserRepository.java b/API/src/main/java/cc/fascinated/repository/UserRepository.java index 7918dbb..e2f17a9 100644 --- a/API/src/main/java/cc/fascinated/repository/UserRepository.java +++ b/API/src/main/java/cc/fascinated/repository/UserRepository.java @@ -25,8 +25,8 @@ public interface UserRepository extends MongoRepository { * * @return the list of users */ - @Query(value = "{}", fields = "{ 'steamId' : 1 }") - List fetchOnlySteamIds(); + @Query(value = "{}", fields = "{ 'steamId' : 1, linkedAccount: 1 }") + List fetchAccountsSimple(); /** * Finds a user by their username. diff --git a/API/src/main/java/cc/fascinated/services/UserService.java b/API/src/main/java/cc/fascinated/services/UserService.java index 87fafed..02e5515 100644 --- a/API/src/main/java/cc/fascinated/services/UserService.java +++ b/API/src/main/java/cc/fascinated/services/UserService.java @@ -105,9 +105,9 @@ public class UserService { * * @return all users */ - public List getUsers(boolean steamIdsOnly) { - if (steamIdsOnly) { - return this.userRepository.fetchOnlySteamIds(); + public List getUsers(boolean smallerAccount) { + if (smallerAccount) { + return this.userRepository.fetchAccountsSimple(); } return this.userRepository.findAll(); }