Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

Commit

Permalink
fix(pagination): bug in pagination
Browse files Browse the repository at this point in the history
The math was wrong for pagination indexes. Simple fix to subtract before multiplying
  • Loading branch information
dtfiedler committed Dec 14, 2023
1 parent 192438d commit 98f191c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/routes/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ export async function contractInteractionsHandler(ctx: KoaContext) {
pageSize: requestedPageSize,
});
// this logic is 1 based
const pageStartIndex = requestedPage - 1 * requestedPageSize;
const pageStartIndex = (requestedPage - 1) * requestedPageSize;
const pageEndIndex = requestedPage * requestedPageSize;
mappedInteractions = mappedInteractions.slice(pageStartIndex, pageEndIndex);
logger.debug('Done paginating interactions', {
Expand All @@ -201,6 +201,8 @@ export async function contractInteractionsHandler(ctx: KoaContext) {
address,
page: requestedPage,
pageSize: requestedPageSize,
pageStartIndex,
pageEndIndex,
totalCount: mappedInteractions.length,
});
}
Expand Down

0 comments on commit 98f191c

Please sign in to comment.