use of com.faforever.api.web.ResourceNotFoundException in project faf-java-api by FAForever.
the class LeaderboardController method getSingleGlobal.
@Async
@RequestMapping(path = "/global/{playerId}", method = RequestMethod.GET)
@ApiOperation("Lists the global leaderboard for the specified player")
public CompletableFuture<JsonApiDocument> getSingleGlobal(@PathVariable("playerId") String playerId) {
GlobalLeaderboardEntry entry = leaderboardService.getGlobalEntry(Integer.valueOf(playerId));
if (entry == null) {
throw new ResourceNotFoundException("No global leaderboard entry found for player: " + playerId);
}
Resource resource = new Resource(GLOBAL_LEADERBOARD_ENTRY, playerId, ImmutableMap.<String, Object>builder().put("name", entry.getPlayerName()).put("mean", entry.getMean()).put("deviation", entry.getDeviation()).put("numGames", entry.getNumGames()).put("rank", entry.getRank()).put("rating", (int) (entry.getMean() - 3 * entry.getDeviation())).build(), null, null, null);
return CompletableFuture.completedFuture(new JsonApiDocument(new Data<>(resource)));
}
use of com.faforever.api.web.ResourceNotFoundException in project faf-java-api by FAForever.
the class LeaderboardController method getSingleLadder1v1.
@Async
@RequestMapping(path = "/ladder1v1/{playerId}", method = RequestMethod.GET)
@ApiOperation("Lists the ladder1v1 leaderboard for the specified player")
public CompletableFuture<JsonApiDocument> getSingleLadder1v1(@PathVariable("playerId") String playerId) {
Ladder1v1LeaderboardEntry entry = leaderboardService.getLadder1v1Entry(Integer.valueOf(playerId));
if (entry == null) {
throw new ResourceNotFoundException("No ladder1v1 entry found for player: " + playerId);
}
Resource resource = new Resource(LADDER_1V1_LEADERBOARD_ENTRY, playerId, ImmutableMap.<String, Object>builder().put("name", entry.getPlayerName()).put("mean", entry.getMean()).put("deviation", entry.getDeviation()).put("numGames", entry.getNumGames()).put("wonGames", entry.getWonGames()).put("rank", entry.getRank()).put("rating", (int) (entry.getMean() - 3 * entry.getDeviation())).build(), null, null, null);
return CompletableFuture.completedFuture(new JsonApiDocument(new Data<>(resource)));
}
Aggregations