tweak return details

This commit is contained in:
Anthony Mineo 2020-09-23 15:03:48 -04:00
parent c10cd44615
commit 98affddbff
4 changed files with 15 additions and 11 deletions

View file

@ -28,8 +28,9 @@ export class GamesController {
// /games/gametype/:gametype
@Get('gametype/:gametype')
@ApiOperation({ tags: [ 'Game' ], summary: 'Return the latest games by game type' })
findByType(@Param('gametype') gametype: string) {
return this.gamesService.findByType(gametype);
findByType(@Param('gametype') gametype: string, @Query() paginationQuery: PaginationQueryDto) {
const { limit = 10, offset = 0 } = paginationQuery;
return this.gamesService.findByType(gametype, { limit, offset });
}
// /games/gametype/CTFGame/summary

View file

@ -34,8 +34,8 @@ export class GamesService {
abvSummary.push(summary);
}
// Only return games when the score is 100 or greater
return abvSummary.filter((g) => g.totalScore >= 100);
// Only return games when the score is greater than 1
return abvSummary.filter((g) => g.totalScore > 1);
}
async findAllWithSummary(paginationQuery: PaginationQueryDto) {
@ -60,11 +60,14 @@ export class GamesService {
return withSummary;
}
async findByType(gametype: string) {
async findByType(gametype: string, paginationQuery: PaginationQueryDto) {
const { limit, offset } = paginationQuery;
const returnMaxLimit = Math.min(100, Math.max(0, limit));
const games = await this.gamesRepository.find({
where: { gametype: gametype },
skip: 0,
take: 10,
skip: offset,
take: returnMaxLimit,
order: {
gameId: 'DESC'
}
@ -79,8 +82,8 @@ export class GamesService {
abvSummary.push(summary);
}
// Only return games when the score is 100 or greater
return abvSummary.filter((g) => g.totalScore >= 100);
// Only return games when the score is greater than 1
return abvSummary.filter((g) => g.totalScore > 1);
}
async findByTypeWithSummary(gametype: string, paginationQuery: PaginationQueryDto) {

View file

@ -81,7 +81,7 @@ export class PlayerService {
Number(player.totalGamesDmgame) +
Number(player.totalGamesSctfgame) +
Number(player.totalGamesLakrabbitgame),
gameDetails: gameDetails.sort((a, b) => b.id - a.id),
gameDetails: gameDetails.sort((a, b) => b.id - a.id).filter((g) => g.stats.scoreTG > 0),
statTotals: playerStatTotals
};

View file

@ -44,7 +44,7 @@ services:
replicas: 1
api:
image: "amineo/t2-stats-api:v0.0.10"
image: "amineo/t2-stats-api:v0.0.12"
build:
context: .
dockerfile: ./build/api/Dockerfile