From 29f5d5983aec428dfb5ede0fea26d96ecc20028e Mon Sep 17 00:00:00 2001 From: Liam Date: Sun, 4 Aug 2024 04:25:51 +0100 Subject: [PATCH] rename statistics to histories --- .../java/cc/fascinated/model/user/User.java | 34 +++++++++---------- .../platform/impl/ScoreSaberPlatform.java | 3 +- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/API/src/main/java/cc/fascinated/model/user/User.java b/API/src/main/java/cc/fascinated/model/user/User.java index f8fda70..f6bb890 100644 --- a/API/src/main/java/cc/fascinated/model/user/User.java +++ b/API/src/main/java/cc/fascinated/model/user/User.java @@ -67,35 +67,35 @@ public class User { /** * The user's statistic history. */ - public Map> statistics; + public Map> histories; /** - * The user's statistic history. + * The user's history points history. */ @JsonIgnore - public Map> getStatistics() { - if (this.statistics == null) { - this.statistics = new HashMap<>(); + public Map> getHistories() { + if (this.histories == null) { + this.histories = new HashMap<>(); } Map> toReturn = new HashMap<>(); - for (Platform.Platforms platform : statistics.keySet()) { - toReturn.put(platform, getStatistic(platform)); + for (Platform.Platforms platform : histories.keySet()) { + toReturn.put(platform, getHistory(platform)); } return toReturn; } /** - * Gets the statistics for a platform. + * Gets the history points for a platform. * * @param platform the platform to get the statistics for * @return the statistics */ @SneakyThrows - public Map getStatistic(@NonNull Platform.Platforms platform) { - if (this.statistics == null) { - this.statistics = new HashMap<>(); + public Map getHistory(@NonNull Platform.Platforms platform) { + if (this.histories == null) { + this.histories = new HashMap<>(); } - Map statisticMap = this.statistics.computeIfAbsent(platform, k -> new HashMap<>()); + Map statisticMap = this.histories.computeIfAbsent(platform, k -> new HashMap<>()); Map statistics = new HashMap<>(); for (Map.Entry entry : statisticMap.entrySet()) { statistics.put(DATE_FORMAT.parse(entry.getKey()), entry.getValue()); @@ -104,17 +104,17 @@ public class User { } /** - * Adds a statistic to the user's history. + * Adds a history point to the user's history. * * @param platform the platform to add the statistic for * @param date the date of the statistic * @param statistic the statistic to add */ - public void addStatistic(@NonNull Platform.Platforms platform, @NonNull Date date, @NonNull Statistic statistic) { - if (this.statistics == null) { - this.statistics = new HashMap<>(); + public void addHistory(@NonNull Platform.Platforms platform, @NonNull Date date, @NonNull Statistic statistic) { + if (this.histories == null) { + this.histories = new HashMap<>(); } - Map statisticMap = this.statistics.computeIfAbsent(platform, k -> new HashMap<>()); + Map statisticMap = this.histories.computeIfAbsent(platform, k -> new HashMap<>()); statisticMap.put(String.valueOf(date.toString()), statistic); } 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 bb058cb..b7402a3 100644 --- a/API/src/main/java/cc/fascinated/platform/impl/ScoreSaberPlatform.java +++ b/API/src/main/java/cc/fascinated/platform/impl/ScoreSaberPlatform.java @@ -138,12 +138,13 @@ public class ScoreSaberPlatform extends Platform { @Override public void updatePlayers() { + Date date = DateUtils.alignToCurrentHour(new Date()); for (User user : this.userService.getUsers(false)) { if (!user.isLinkedAccount()) { // Check if the user has linked their account continue; } ScoreSaberAccountToken account = scoreSaberService.getAccount(user); // Get the account from the ScoreSaber API - user.addStatistic(this.getPlatform(), DateUtils.alignToCurrentHour(new Date()), new ScoreSaberStatistic( + user.addHistory(this.getPlatform(), date, new ScoreSaberStatistic( account.getRank(), account.getCountryRank(), account.getScoreStats().getTotalScore(),