diff --git a/pom.xml b/pom.xml index ca96e97..184ad5f 100644 --- a/pom.xml +++ b/pom.xml @@ -83,6 +83,14 @@ 2.9.1 + + + io.sentry + sentry-spring-boot-starter-jakarta + 7.8.0 + compile + + org.springframework.boot diff --git a/src/main/java/cc/fascinated/backend/exception/ExceptionControllerAdvice.java b/src/main/java/cc/fascinated/backend/exception/ExceptionControllerAdvice.java index 5d9cc6e..69f8a45 100644 --- a/src/main/java/cc/fascinated/backend/exception/ExceptionControllerAdvice.java +++ b/src/main/java/cc/fascinated/backend/exception/ExceptionControllerAdvice.java @@ -2,6 +2,7 @@ package cc.fascinated.backend.exception; import cc.fascinated.backend.model.response.ErrorResponse; import io.micrometer.common.lang.NonNull; +import io.sentry.Sentry; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; @@ -39,6 +40,7 @@ public final class ExceptionControllerAdvice { } if (status == null) { // Fallback to 500 status = HttpStatus.INTERNAL_SERVER_ERROR; + Sentry.captureException(ex); // Capture the exception } return new ResponseEntity<>(new ErrorResponse(status, message), status); } diff --git a/src/main/java/cc/fascinated/backend/repository/ScoreRepository.java b/src/main/java/cc/fascinated/backend/repository/ScoreRepository.java index 2635b0d..47a56fa 100644 --- a/src/main/java/cc/fascinated/backend/repository/ScoreRepository.java +++ b/src/main/java/cc/fascinated/backend/repository/ScoreRepository.java @@ -18,7 +18,7 @@ public interface ScoreRepository extends MongoRepository { * @return The scores for the account. */ @Query("{ 'accountId' : ?0 }") - List getScoresForAccount(String accountId); + List getScores(String accountId); /** * Gets the ranked scores for an account. @@ -27,7 +27,7 @@ public interface ScoreRepository extends MongoRepository { * @return The ranked scores for the account. */ @Query(value = "{ 'accountId' : ?0, 'pp' : { $gt : 0 } }", sort = "{ 'pp' : -1 }") - List getRankedScoresForAccount(String accountId); + List getRankedScores(String accountId); /** * Gets the scores sorted by the newest for an account. @@ -37,4 +37,14 @@ public interface ScoreRepository extends MongoRepository { */ @Query(value = "{ 'accountId' : ?0 }", sort = "{ 'timeSet' : -1 }") List getScoresSortedByNewest(String accountId); + + /** + * Gets the scores for an account and a leaderboard. + * + * @param accountId The id of the account. + * @param leaderboardId The id of the leaderboard. + * @return The scores for the leaderboard. + */ + @Query(value = "{ 'accountId' : ?0, 'leaderboardId' : ?1 }", sort = "{ 'timeSet' : -1 }") + List getScoreForLeaderboard(String accountId, String leaderboardId); } diff --git a/src/main/java/cc/fascinated/backend/service/AccountService.java b/src/main/java/cc/fascinated/backend/service/AccountService.java index 6265b1a..ea17de8 100644 --- a/src/main/java/cc/fascinated/backend/service/AccountService.java +++ b/src/main/java/cc/fascinated/backend/service/AccountService.java @@ -105,7 +105,7 @@ public class AccountService { scoreSaberService.updateScores(account); // Set the raw pp per +1 global pp - double rawPerGlobalPP = ScoreSaberLeaderboard.INSTANCE.getRawPerGlobalPP(scoreRepository.getRankedScoresForAccount(id), 1); + double rawPerGlobalPP = ScoreSaberLeaderboard.INSTANCE.getRawPerGlobalPP(scoreRepository.getRankedScores(id), 1); account.setRawPerGlobalPerformancePoints(rawPerGlobalPP); return accountRepository.save(account); } diff --git a/src/main/java/cc/fascinated/backend/service/ScoreSaberService.java b/src/main/java/cc/fascinated/backend/service/ScoreSaberService.java index fbb6348..f324967 100644 --- a/src/main/java/cc/fascinated/backend/service/ScoreSaberService.java +++ b/src/main/java/cc/fascinated/backend/service/ScoreSaberService.java @@ -136,7 +136,7 @@ public class ScoreSaberService extends TextWebSocketHandler { String name = account.getName(); // Fetch the scores for the account. - List scores = scoreRepository.getScoresForAccount(account.getId()); + List scores = scoreRepository.getScores(account.getId()); if (scores.isEmpty()) { log.warn("Account '{}' has no scores, fetching them.", name); diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index eb087ec..0f39eab 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -15,6 +15,11 @@ spring: uri: mongodb://localhost:27017 database: ssu-prod +# Sentry Configuration +sentry: + dsn: "" + tracesSampleRate: 1.0 + # Set the embedded MongoDB version de: flapdoodle: