This commit is contained in:
parent
3f5eff3d1a
commit
560fce9b01
@ -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
|
||||
|
@ -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.
|
||||
*
|
||||
|
@ -31,6 +31,7 @@ public class TrackedScoreService {
|
||||
@Autowired
|
||||
public TrackedScoreService(@NonNull TrackedScoreRepository trackedScoreRepository) {
|
||||
this.trackedScoreRepository = trackedScoreRepository;
|
||||
this.trackedScoreRepository.ensureDeduplication();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user