meow
All checks were successful
Deploy to Dokku / docker (ubuntu-latest) (push) Successful in 39s

This commit is contained in:
Lee 2024-08-01 01:22:13 +01:00
parent 3f5eff3d1a
commit 560fce9b01
3 changed files with 9 additions and 15 deletions

View File

@ -195,22 +195,8 @@ public class ScoreSaberPlatform extends Platform {
this.getPlatform().getPlatformName()
);
int finished = 0;
// Delete duplicated score ids
List<TrackedScore> duplicatedScores = scores.stream().filter(score -> {
long count = scores.stream().filter(s -> s.getScoreId().equals(score.getScoreId())).count();
return count > 1;
}).toList();
if (!duplicatedScores.isEmpty()) {
this.trackedScoreService.deleteScores(duplicatedScores.toArray(TrackedScore[]::new));
log.info("Deleted {} duplicated scores for platform '{}'",
duplicatedScores.size(),
this.getPlatform().getPlatformName()
);
}
// Update the leaderboards
int finished = 0;
for (String id : uniqueLeaderboardIds) {
try {
ScoreSaberLeaderboardToken leaderboard = this.scoreSaberService.getLeaderboard(id, true); // Update the cached leaderboard

View File

@ -13,6 +13,13 @@ import java.util.List;
* @author Fascinated (fascinated7)
*/
public interface TrackedScoreRepository extends CrudRepository<TrackedScore, String> {
/**
* Ensures that the deduplication of the scores is done.
*/
@Modifying @Transactional
@Query(value = "ALTER TABLE score DEDUP ENABLE UPSERT KEYS(timestamp, score_id)", nativeQuery = true)
void ensureDeduplication();
/**
* Updates the pp of a score.
*

View File

@ -31,6 +31,7 @@ public class TrackedScoreService {
@Autowired
public TrackedScoreService(@NonNull TrackedScoreRepository trackedScoreRepository) {
this.trackedScoreRepository = trackedScoreRepository;
this.trackedScoreRepository.ensureDeduplication();
}
/**