Skip to content

Commit

Permalink
feat: updated model of pagination information
Browse files Browse the repository at this point in the history
  • Loading branch information
JanssenBrm committed Dec 6, 2024
1 parent 3883f77 commit a4423b8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
15 changes: 13 additions & 2 deletions src/jobs/models/pagination.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
7 changes: 2 additions & 5 deletions src/jobs/services/database/database.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
};
}
Expand Down

0 comments on commit a4423b8

Please sign in to comment.