This commit is contained in:
parent
1efab2ed08
commit
09834e9eac
@ -187,7 +187,7 @@ public class ScoreSaberPlatform extends Platform {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateLeaderboards() {
|
public void updateLeaderboards() {
|
||||||
List<TrackedScore> scores = this.trackedScoreService.getTrackedScores(this.getPlatform(), true);
|
List<TrackedScore> scores = this.trackedScoreService.getTrackedScores(this.getPlatform(), false);
|
||||||
List<String> leaderboardIds = scores.stream().map(TrackedScore::getLeaderboardId).toList();
|
List<String> leaderboardIds = scores.stream().map(TrackedScore::getLeaderboardId).toList();
|
||||||
|
|
||||||
log.info("Updating {} leaderboards for platform '{}'",
|
log.info("Updating {} leaderboards for platform '{}'",
|
||||||
@ -197,6 +197,19 @@ public class ScoreSaberPlatform extends Platform {
|
|||||||
|
|
||||||
int finished = 0;
|
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
|
// Update the leaderboards
|
||||||
for (String id : leaderboardIds) {
|
for (String id : leaderboardIds) {
|
||||||
try {
|
try {
|
||||||
|
@ -85,8 +85,8 @@ public class TrackedScoreService {
|
|||||||
* @param platform the platform to get the scores from
|
* @param platform the platform to get the scores from
|
||||||
* @return the tracked scores
|
* @return the tracked scores
|
||||||
*/
|
*/
|
||||||
public List<TrackedScore> getTrackedScores(Platform.Platforms platform, boolean ranked) {
|
public List<TrackedScore> getTrackedScores(Platform.Platforms platform, boolean onlyRanked) {
|
||||||
if (ranked) {
|
if (onlyRanked) {
|
||||||
return trackedScoreRepository.findAllByPlatformRankedOnly(platform.getPlatformName());
|
return trackedScoreRepository.findAllByPlatformRankedOnly(platform.getPlatformName());
|
||||||
}
|
}
|
||||||
return trackedScoreRepository.findAllByPlatform(platform.getPlatformName());
|
return trackedScoreRepository.findAllByPlatform(platform.getPlatformName());
|
||||||
@ -102,4 +102,15 @@ public class TrackedScoreService {
|
|||||||
this.trackedScoreRepository.updateScorePp(score.getScoreId(), score.getPp());
|
this.trackedScoreRepository.updateScorePp(score.getScoreId(), score.getPp());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes a list of tracked scores.
|
||||||
|
*
|
||||||
|
* @param scores the scores to delete
|
||||||
|
*/
|
||||||
|
public void deleteScores(TrackedScore... scores) {
|
||||||
|
for (TrackedScore score : scores) {
|
||||||
|
this.trackedScoreRepository.delete(score);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user