diff --git a/server/src/repository/play.ts b/server/src/repository/play.ts index 8038935..b925d27 100644 --- a/server/src/repository/play.ts +++ b/server/src/repository/play.ts @@ -49,10 +49,12 @@ export class PlayRepository { const subQuery = qb.subQuery().select('max(round_id)').from(Play, 'maxp').getQuery(); return 'round_id = ' + subQuery; }) - .limit(pagination.limit) - .offset(pagination.offset) .orderBy('timestamp', 'DESC'); + if (pagination.limit !== -1) { + queryBuilder.limit(pagination.limit).offset(pagination.offset); + } + return queryBuilder.getManyAndCount(); } diff --git a/server/src/repository/round.ts b/server/src/repository/round.ts index fea9750..fbe6ddd 100644 --- a/server/src/repository/round.ts +++ b/server/src/repository/round.ts @@ -10,13 +10,16 @@ export class RoundRepository { async getPaginatedRounds(pagination: { limit: number; offset: number }, params: { isFinished: boolean } = { isFinished: false }): Promise<[Round[], number]> { const options: FindManyOptions = { - take: pagination.limit, - skip: pagination.offset, order: { roundId: 'DESC', }, }; + if (pagination.limit !== -1) { + options.take = pagination.limit; + options.skip = pagination.offset; + } + if (params.isFinished) { options.where = { isFinished: true }; }