add Sentry
All checks were successful
Deploy App / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Successful in 1m31s
All checks were successful
Deploy App / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Successful in 1m31s
This commit is contained in:
parent
d96a38a996
commit
8d1ef26183
8
pom.xml
8
pom.xml
@ -83,6 +83,14 @@
|
||||
<version>2.9.1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Sentry -->
|
||||
<dependency>
|
||||
<groupId>io.sentry</groupId>
|
||||
<artifactId>sentry-spring-boot-starter-jakarta</artifactId>
|
||||
<version>7.8.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Websockets -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ public interface ScoreRepository extends MongoRepository<Score, String> {
|
||||
* @return The scores for the account.
|
||||
*/
|
||||
@Query("{ 'accountId' : ?0 }")
|
||||
List<Score> getScoresForAccount(String accountId);
|
||||
List<Score> getScores(String accountId);
|
||||
|
||||
/**
|
||||
* Gets the ranked scores for an account.
|
||||
@ -27,7 +27,7 @@ public interface ScoreRepository extends MongoRepository<Score, String> {
|
||||
* @return The ranked scores for the account.
|
||||
*/
|
||||
@Query(value = "{ 'accountId' : ?0, 'pp' : { $gt : 0 } }", sort = "{ 'pp' : -1 }")
|
||||
List<Score> getRankedScoresForAccount(String accountId);
|
||||
List<Score> getRankedScores(String accountId);
|
||||
|
||||
/**
|
||||
* Gets the scores sorted by the newest for an account.
|
||||
@ -37,4 +37,14 @@ public interface ScoreRepository extends MongoRepository<Score, String> {
|
||||
*/
|
||||
@Query(value = "{ 'accountId' : ?0 }", sort = "{ 'timeSet' : -1 }")
|
||||
List<Score> 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<Score> getScoreForLeaderboard(String accountId, String leaderboardId);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ public class ScoreSaberService extends TextWebSocketHandler {
|
||||
String name = account.getName();
|
||||
|
||||
// Fetch the scores for the account.
|
||||
List<Score> scores = scoreRepository.getScoresForAccount(account.getId());
|
||||
List<Score> scores = scoreRepository.getScores(account.getId());
|
||||
if (scores.isEmpty()) {
|
||||
log.warn("Account '{}' has no scores, fetching them.", name);
|
||||
|
||||
|
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user