diff --git a/src/main/java/cc/fascinated/controller/ScoresController.java b/src/main/java/cc/fascinated/controller/ScoresController.java index b813f53..caec388 100644 --- a/src/main/java/cc/fascinated/controller/ScoresController.java +++ b/src/main/java/cc/fascinated/controller/ScoresController.java @@ -47,7 +47,7 @@ public class ScoresController { * amount of scores for a platform * * @param platform the platform to get the scores from - * @return the amount scores + * @return the amount of scores * @throws BadRequestException if there were no scores found */ @ResponseBody @@ -55,4 +55,18 @@ public class ScoresController { public ResponseEntity getScoresCount(@PathVariable String platform) { return ResponseEntity.ok(trackedScoreService.getTotalScores(Platform.Platforms.getPlatform(platform))); } + + /** + * A GET mapping to retrieve the total + * amount of scores over pp thresholds + * + * @param platform the platform to get the scores from + * @return the amount of scores + * @throws BadRequestException if there were no scores found + */ + @ResponseBody + @GetMapping(value = "/ppthresholds/{platform}") + public ResponseEntity getScoresOver(@PathVariable String platform) { + return ResponseEntity.ok(trackedScoreService.getScoresOver(Platform.Platforms.getPlatform(platform))); + } } diff --git a/src/main/java/cc/fascinated/model/score/ScoresOverResponse.java b/src/main/java/cc/fascinated/model/score/ScoresOverResponse.java new file mode 100644 index 0000000..8db77d0 --- /dev/null +++ b/src/main/java/cc/fascinated/model/score/ScoresOverResponse.java @@ -0,0 +1,24 @@ +package cc.fascinated.model.score; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author Fascinated (fascinated7) + */ +public class ScoresOverResponse { + /** + * Scores over a certain pp threshold. + */ + public Map scoresOver = new HashMap<>(); + + /** + * Adds scores over a certain pp threshold. + * + * @param pp the pp threshold + * @param scoreAmount the amount of scores over the pp threshold + */ + public void addScores(int pp, int scoreAmount) { + scoresOver.put(pp, scoreAmount); + } +} diff --git a/src/main/java/cc/fascinated/model/score/TotalScoresMetric.java b/src/main/java/cc/fascinated/model/score/TotalScoresResponse.java similarity index 90% rename from src/main/java/cc/fascinated/model/score/TotalScoresMetric.java rename to src/main/java/cc/fascinated/model/score/TotalScoresResponse.java index 6ef4412..cd03aeb 100644 --- a/src/main/java/cc/fascinated/model/score/TotalScoresMetric.java +++ b/src/main/java/cc/fascinated/model/score/TotalScoresResponse.java @@ -8,7 +8,7 @@ import lombok.Getter; */ @AllArgsConstructor @Getter -public class TotalScoresMetric { +public class TotalScoresResponse { /** * The total number of scores */ diff --git a/src/main/java/cc/fascinated/model/score/TrackedScore.java b/src/main/java/cc/fascinated/model/score/TrackedScore.java index 4f89602..9a223df 100644 --- a/src/main/java/cc/fascinated/model/score/TrackedScore.java +++ b/src/main/java/cc/fascinated/model/score/TrackedScore.java @@ -2,7 +2,6 @@ package cc.fascinated.model.score; import jakarta.persistence.Entity; import jakarta.persistence.Id; -import lombok.AllArgsConstructor; import lombok.Getter; /** diff --git a/src/main/java/cc/fascinated/platform/impl/ScoreSaberPlatform.java b/src/main/java/cc/fascinated/platform/impl/ScoreSaberPlatform.java index 53eb961..9070fbf 100644 --- a/src/main/java/cc/fascinated/platform/impl/ScoreSaberPlatform.java +++ b/src/main/java/cc/fascinated/platform/impl/ScoreSaberPlatform.java @@ -1,7 +1,6 @@ package cc.fascinated.platform.impl; -import cc.fascinated.model.score.TotalScoresMetric; -import cc.fascinated.model.score.TrackedScore; +import cc.fascinated.model.score.TotalScoresResponse; import cc.fascinated.model.token.ScoreSaberAccountToken; import cc.fascinated.model.user.User; import cc.fascinated.platform.Platform; @@ -82,7 +81,7 @@ public class ScoreSaberPlatform extends Platform { @Override public void updateMetrics() { try (Sender sender = questDBService.getSender()) { - TotalScoresMetric totalScores = trackedScoreService.getTotalScores(this.getPlatform()); + TotalScoresResponse totalScores = trackedScoreService.getTotalScores(this.getPlatform()); sender.table("metrics") .symbol("platform", this.getPlatform().getPlatformName()) .longColumn("total_scores", totalScores.getTotalScores()) diff --git a/src/main/java/cc/fascinated/repository/couchdb/TrackedScoreRepository.java b/src/main/java/cc/fascinated/repository/couchdb/TrackedScoreRepository.java index 9068cb0..4153d36 100644 --- a/src/main/java/cc/fascinated/repository/couchdb/TrackedScoreRepository.java +++ b/src/main/java/cc/fascinated/repository/couchdb/TrackedScoreRepository.java @@ -41,4 +41,13 @@ public interface TrackedScoreRepository extends CrudRepository