api: add /improved/best/{platform}
endpoint
Some checks failed
Deploy API / docker (17, 3.8.5) (push) Failing after 33s
Some checks failed
Deploy API / docker (17, 3.8.5) (push) Failing after 33s
This commit is contained in:
parent
199ee50534
commit
de309ea05c
@ -98,4 +98,21 @@ public class ScoresController {
|
|||||||
30
|
30
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A GET mapping to retrieve the score
|
||||||
|
* history for a leaderboard
|
||||||
|
*
|
||||||
|
* @param platform the platform to get the history from
|
||||||
|
* @return the score history
|
||||||
|
* @throws BadRequestException if there were no history found
|
||||||
|
*/
|
||||||
|
@ResponseBody
|
||||||
|
@GetMapping(value = "/improved/best/{platform}")
|
||||||
|
public ResponseEntity<?> getBestImprovedScores(@PathVariable String platform) {
|
||||||
|
return ResponseEntity.ok(scoreService.getBestImprovedScores(
|
||||||
|
Platform.Platforms.getPlatform(platform),
|
||||||
|
30
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,21 @@ public interface ScoreRepository extends MongoRepository<Score, String> {
|
|||||||
"{ $match: { 'previousScores.0': { $exists: true } } }",
|
"{ $match: { 'previousScores.0': { $exists: true } } }",
|
||||||
"{ $sort: { pp: -1 } }"
|
"{ $sort: { pp: -1 } }"
|
||||||
})
|
})
|
||||||
List<Score> getImprovedScores(@NonNull Platform.Platforms platform, @NonNull String playerId, @NonNull Date after);
|
List<Score> getUserImprovedScores(@NonNull Platform.Platforms platform, @NonNull String playerId, @NonNull Date after);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the best improved scores from the platform.
|
||||||
|
*
|
||||||
|
* @param platform the platform to get the scores from
|
||||||
|
* @param after the date to get the scores after
|
||||||
|
* @return the scores
|
||||||
|
*/
|
||||||
|
@Aggregation(pipeline = {
|
||||||
|
"{ $match: { platform: ?0, timestamp: { $gt: ?1 } } }",
|
||||||
|
"{ $match: { 'previousScores.0': { $exists: true } } }",
|
||||||
|
"{ $sort: { pp: -1 } }"
|
||||||
|
})
|
||||||
|
List<Score> getBestImprovedScores(@NonNull Platform.Platforms platform, @NonNull Date after);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a score from a platform and leaderboard id.
|
* Gets a score from a platform and leaderboard id.
|
||||||
|
@ -225,7 +225,18 @@ public class ScoreService {
|
|||||||
* @return The improved scores.
|
* @return The improved scores.
|
||||||
*/
|
*/
|
||||||
public List<Score> getImprovedScores(@NonNull Platform.Platforms platform, @NonNull User user, int days) {
|
public List<Score> getImprovedScores(@NonNull Platform.Platforms platform, @NonNull User user, int days) {
|
||||||
return scoreRepository.getImprovedScores(platform, user.getSteamId(), DateUtils.getDaysAgo(days));
|
return scoreRepository.getUserImprovedScores(platform, user.getSteamId(), DateUtils.getDaysAgo(days));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the best improved scores from the platform.
|
||||||
|
*
|
||||||
|
* @param platform The platform to get the scores from.
|
||||||
|
* @param days The amount of days in the past to get the scores from.
|
||||||
|
* @return The scores.
|
||||||
|
*/
|
||||||
|
public List<Score> getBestImprovedScores(@NonNull Platform.Platforms platform, int days) {
|
||||||
|
return scoreRepository.getBestImprovedScores(platform, DateUtils.getDaysAgo(days));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user