From a4423b8d892f5b874626be72f34cfef33b237792 Mon Sep 17 00:00:00 2001 From: bramjanssen Date: Fri, 6 Dec 2024 08:03:50 +0100 Subject: [PATCH] feat: updated model of pagination information --- src/jobs/models/pagination.dto.ts | 15 +++++++++++++-- src/jobs/services/database/database.service.ts | 7 ++----- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/jobs/models/pagination.dto.ts b/src/jobs/models/pagination.dto.ts index 8407847..2306a29 100644 --- a/src/jobs/models/pagination.dto.ts +++ b/src/jobs/models/pagination.dto.ts @@ -19,9 +19,20 @@ export class PaginationDetails { @ApiProperty({ description: 'URL parameters to use to fetch the previous page', }) - previous?: string; + previous?: PageDetails; @ApiProperty({ description: 'URL parameters to use to fetch the next page', }) - next?: string; + next?: PageDetails; +} + +export class PageDetails { + @ApiProperty({ + description: 'Size to be requested for the next page', + }) + size: number; + @ApiProperty({ + description: 'Number of the page to request', + }) + page: number; } diff --git a/src/jobs/services/database/database.service.ts b/src/jobs/services/database/database.service.ts index 6969906..f5049be 100644 --- a/src/jobs/services/database/database.service.ts +++ b/src/jobs/services/database/database.service.ts @@ -146,11 +146,8 @@ export class DatabaseService { return { jobs, pagination: { - previous: page > 0 ? `size=${size}&page=${page - 1}` : null, - next: - body.hits.hits.length === size - ? `size=${size}&page=${page + 1}` - : null, + previous: page > 0 ? { size, page: page - 1 } : null, + next: body.hits.hits.length === size ? { size, page: page + 1 } : null, }, }; }