From 9e40b300f5302ecc118ed337e0918a6fd52f156a Mon Sep 17 00:00:00 2001 From: Anthony Mineo Date: Mon, 21 Sep 2020 12:09:21 -0400 Subject: [PATCH] Tweak return limits --- app/api/src/games/games.service.ts | 14 +++++++++++--- app/api/src/players/players.service.ts | 7 +++++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/app/api/src/games/games.service.ts b/app/api/src/games/games.service.ts index 94fdf46..2482c28 100644 --- a/app/api/src/games/games.service.ts +++ b/app/api/src/games/games.service.ts @@ -18,9 +18,11 @@ export class GamesService { async findAll(paginationQuery: PaginationQueryDto) { const { limit, offset } = paginationQuery; + const returnMaxLimit = Math.min(300, Math.max(0, limit)); + const games = await this.gamesRepository.find({ skip: offset, - take: limit, + take: returnMaxLimit, order: { gameId: 'DESC' } @@ -31,9 +33,12 @@ export class GamesService { async findAllWithSummary(paginationQuery: PaginationQueryDto) { const { limit, offset } = paginationQuery; + + const returnMaxLimit = Math.min(100, Math.max(0, limit)); + const games = await this.gamesRepository.find({ skip: offset, - take: limit, + take: returnMaxLimit, order: { gameId: 'DESC' } @@ -67,10 +72,13 @@ export class GamesService { async findByTypeWithSummary(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: offset, - take: limit, + take: returnMaxLimit, order: { gameId: 'DESC' } diff --git a/app/api/src/players/players.service.ts b/app/api/src/players/players.service.ts index 860f024..176ba5a 100644 --- a/app/api/src/players/players.service.ts +++ b/app/api/src/players/players.service.ts @@ -18,11 +18,14 @@ export class PlayersService { async findAll(paginationQuery: PaginationQueryDto) { const { limit, offset } = paginationQuery; + + const returnMaxLimit = Math.min(300, Math.max(0, limit)); + const players = await this.playersRepository.find({ skip: offset, - take: limit, + take: returnMaxLimit, order: { - playerName: 'DESC' + updatedAt: 'DESC' } });