From c2e1627a7f76bbdb236240bb17168e63c9cf112e Mon Sep 17 00:00:00 2001 From: Pranav C Date: Wed, 10 Jan 2024 13:38:30 +0000 Subject: [PATCH] fix: avoid fractional page value --- packages/nocodb/src/helpers/PagedResponse.ts | 7 ++++++- packages/nocodb/src/schema/swagger.json | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/nocodb/src/helpers/PagedResponse.ts b/packages/nocodb/src/helpers/PagedResponse.ts index 86e1c5e20d..72b3714d46 100644 --- a/packages/nocodb/src/helpers/PagedResponse.ts +++ b/packages/nocodb/src/helpers/PagedResponse.ts @@ -28,8 +28,13 @@ export class PagedResponseImpl { this.pageInfo.isFirstPage = this.pageInfo.isFirstPage ?? this.pageInfo.page === 1; this.pageInfo.isLastPage = - this.pageInfo.page === + this.pageInfo.page >= (Math.ceil(this.pageInfo.totalRows / this.pageInfo.pageSize) || 1); + + if (this.pageInfo.page % 1 !== 0) { + this.pageInfo.offset = offset; + delete this.pageInfo.page; + } } if (additionalProps) Object.assign(this, additionalProps); diff --git a/packages/nocodb/src/schema/swagger.json b/packages/nocodb/src/schema/swagger.json index f15b733ffa..6881c617e3 100644 --- a/packages/nocodb/src/schema/swagger.json +++ b/packages/nocodb/src/schema/swagger.json @@ -20645,6 +20645,11 @@ "example": 1, "type": "number" }, + "offset": { + "description": "The current offset and it will be present only when the page is not included", + "example": 1, + "type": "number" + }, "pageSize": { "description": "The number of pages", "example": 10,