+ * eg: 00:05 -> 00:00 + *
+ * + * @param date The date to align. + * @return The aligned date. + */ + public static Date alignToCurrentHour(Date date) { + return Date.from(Instant.ofEpochMilli(date.getTime()).truncatedTo(ChronoUnit.HOURS)); + } } 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 fbfc9bf..3908c93 100644 --- a/API/src/main/java/cc/fascinated/model/user/User.java +++ b/API/src/main/java/cc/fascinated/model/user/User.java @@ -1,15 +1,17 @@ package cc.fascinated.model.user; +import cc.fascinated.model.user.statistic.Statistic; +import cc.fascinated.platform.Platform; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Getter; -import lombok.RequiredArgsConstructor; -import lombok.Setter; -import lombok.ToString; +import lombok.*; import org.springframework.data.annotation.Id; import org.springframework.data.mongodb.core.index.Indexed; import org.springframework.data.mongodb.core.mapping.Document; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; import java.util.UUID; /** @@ -24,7 +26,8 @@ public class User { /** * The ID of the user. */ - @Id @JsonIgnore + @Id + @JsonIgnore private final UUID id; /** @@ -39,7 +42,8 @@ public class User { /** * The ID of the users steam profile. */ - @Indexed @JsonProperty("id") + @Indexed + @JsonProperty("id") private String steamId; /** @@ -56,4 +60,31 @@ public class User { * The user's ScoreSaber account. */ public ScoreSaberAccount scoresaberAccount; + + /** + * The user's statistic history. + */ + @JsonIgnore + public Map- * This method is scheduled to run every 15 minutes. + * This method is scheduled to run every day at midnight. *
*/ - @Scheduled(cron = "0 */15 * * * *") + @Scheduled(cron = "0 0 0 * * *") public void updatePlayerMetrics() { log.info("Updating %s platform player metrics...".formatted(this.platforms.size())); for (Platform platform : this.platforms) { diff --git a/API/src/main/java/cc/fascinated/services/ScoreSaberService.java b/API/src/main/java/cc/fascinated/services/ScoreSaberService.java index c28a875..91dad97 100644 --- a/API/src/main/java/cc/fascinated/services/ScoreSaberService.java +++ b/API/src/main/java/cc/fascinated/services/ScoreSaberService.java @@ -6,7 +6,7 @@ import cc.fascinated.model.token.ScoreSaberAccountToken; import cc.fascinated.model.token.ScoreSaberLeaderboardPageToken; import cc.fascinated.model.token.ScoreSaberLeaderboardToken; import cc.fascinated.model.user.User; -import cc.fascinated.repository.mongo.ScoreSaberLeaderboardRepository; +import cc.fascinated.repository.ScoreSaberLeaderboardRepository; import kong.unirest.core.HttpResponse; import lombok.NonNull; import lombok.extern.log4j.Log4j2; diff --git a/API/src/main/java/cc/fascinated/services/ScoreService.java b/API/src/main/java/cc/fascinated/services/ScoreService.java index bc8258f..17eda03 100644 --- a/API/src/main/java/cc/fascinated/services/ScoreService.java +++ b/API/src/main/java/cc/fascinated/services/ScoreService.java @@ -13,7 +13,7 @@ import cc.fascinated.model.token.ScoreSaberPlayerScoreToken; import cc.fascinated.model.token.ScoreSaberScoreToken; import cc.fascinated.model.user.User; import cc.fascinated.platform.Platform; -import cc.fascinated.repository.mongo.ScoreRepository; +import cc.fascinated.repository.ScoreRepository; import lombok.NonNull; import lombok.extern.log4j.Log4j2; import org.springframework.beans.factory.annotation.Autowired; diff --git a/API/src/main/java/cc/fascinated/services/UserService.java b/API/src/main/java/cc/fascinated/services/UserService.java index d8f7921..357b572 100644 --- a/API/src/main/java/cc/fascinated/services/UserService.java +++ b/API/src/main/java/cc/fascinated/services/UserService.java @@ -5,7 +5,7 @@ import cc.fascinated.exception.impl.BadRequestException; import cc.fascinated.model.token.ScoreSaberAccountToken; import cc.fascinated.model.user.ScoreSaberAccount; import cc.fascinated.model.user.User; -import cc.fascinated.repository.mongo.UserRepository; +import cc.fascinated.repository.UserRepository; import lombok.NonNull; import lombok.extern.log4j.Log4j2; import org.springframework.beans.factory.annotation.Autowired;