From 98affddbff92bafcc48c9d6f63f224072e2644a7 Mon Sep 17 00:00:00 2001 From: Anthony Mineo Date: Wed, 23 Sep 2020 15:03:48 -0400 Subject: [PATCH] tweak return details --- app/api/src/games/games.controller.ts | 5 +++-- app/api/src/games/games.service.ts | 17 ++++++++++------- app/api/src/player/player.service.ts | 2 +- docker-compose.yml | 2 +- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/app/api/src/games/games.controller.ts b/app/api/src/games/games.controller.ts index f90f164..a76794f 100644 --- a/app/api/src/games/games.controller.ts +++ b/app/api/src/games/games.controller.ts @@ -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 diff --git a/app/api/src/games/games.service.ts b/app/api/src/games/games.service.ts index 40af763..8d598a5 100644 --- a/app/api/src/games/games.service.ts +++ b/app/api/src/games/games.service.ts @@ -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) { diff --git a/app/api/src/player/player.service.ts b/app/api/src/player/player.service.ts index 9a0b9ad..470f717 100644 --- a/app/api/src/player/player.service.ts +++ b/app/api/src/player/player.service.ts @@ -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 }; diff --git a/docker-compose.yml b/docker-compose.yml index ca69a1b..dec3f73 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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