Tweak return limits

This commit is contained in:
Anthony Mineo 2020-09-21 12:09:21 -04:00
parent 8e5cf83d4d
commit 9e40b300f5
2 changed files with 16 additions and 5 deletions

View file

@ -18,9 +18,11 @@ export class GamesService {
async findAll(paginationQuery: PaginationQueryDto) { async findAll(paginationQuery: PaginationQueryDto) {
const { limit, offset } = paginationQuery; const { limit, offset } = paginationQuery;
const returnMaxLimit = Math.min(300, Math.max(0, limit));
const games = await this.gamesRepository.find({ const games = await this.gamesRepository.find({
skip: offset, skip: offset,
take: limit, take: returnMaxLimit,
order: { order: {
gameId: 'DESC' gameId: 'DESC'
} }
@ -31,9 +33,12 @@ export class GamesService {
async findAllWithSummary(paginationQuery: PaginationQueryDto) { async findAllWithSummary(paginationQuery: PaginationQueryDto) {
const { limit, offset } = paginationQuery; const { limit, offset } = paginationQuery;
const returnMaxLimit = Math.min(100, Math.max(0, limit));
const games = await this.gamesRepository.find({ const games = await this.gamesRepository.find({
skip: offset, skip: offset,
take: limit, take: returnMaxLimit,
order: { order: {
gameId: 'DESC' gameId: 'DESC'
} }
@ -67,10 +72,13 @@ export class GamesService {
async findByTypeWithSummary(gametype: string, paginationQuery: PaginationQueryDto) { async findByTypeWithSummary(gametype: string, paginationQuery: PaginationQueryDto) {
const { limit, offset } = paginationQuery; const { limit, offset } = paginationQuery;
const returnMaxLimit = Math.min(100, Math.max(0, limit));
const games = await this.gamesRepository.find({ const games = await this.gamesRepository.find({
where: { gametype: gametype }, where: { gametype: gametype },
skip: offset, skip: offset,
take: limit, take: returnMaxLimit,
order: { order: {
gameId: 'DESC' gameId: 'DESC'
} }

View file

@ -18,11 +18,14 @@ export class PlayersService {
async findAll(paginationQuery: PaginationQueryDto) { async findAll(paginationQuery: PaginationQueryDto) {
const { limit, offset } = paginationQuery; const { limit, offset } = paginationQuery;
const returnMaxLimit = Math.min(300, Math.max(0, limit));
const players = await this.playersRepository.find({ const players = await this.playersRepository.find({
skip: offset, skip: offset,
take: limit, take: returnMaxLimit,
order: { order: {
playerName: 'DESC' updatedAt: 'DESC'
} }
}); });