From 48ef59aece3870b1b9e4ef9b93b35ff6680180f2 Mon Sep 17 00:00:00 2001 From: rooki Date: Fri, 9 Aug 2024 18:39:28 +0200 Subject: [PATCH] Fix pagination to start from page 1 instead of 0. Previously, the pagination logic treated negative and zero page indices the same, defaulting to 0. This change ensures that the first page starts from 1, aligning with typical pagination conventions. Signed-off-by: rooki --- .../sublinksapi/post/services/PostSearchQueryService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/sublinks/sublinksapi/post/services/PostSearchQueryService.java b/src/main/java/com/sublinks/sublinksapi/post/services/PostSearchQueryService.java index ae94ae0a..18965225 100644 --- a/src/main/java/com/sublinks/sublinksapi/post/services/PostSearchQueryService.java +++ b/src/main/java/com/sublinks/sublinksapi/post/services/PostSearchQueryService.java @@ -70,7 +70,7 @@ public Results setPerPage(final Integer perPage) { public Results setPage(final Integer page) { - int p = Math.max(Math.abs(page), 0); + int p = Math.max(Math.abs(page), 1); getQuery().setFirstResult((p - 1) * this.getPerPage()); return this; }