Skip to content

Commit

Permalink
interactions loader - previous sk instead of offset
Browse files Browse the repository at this point in the history
  • Loading branch information
Tadeuchi committed Dec 20, 2023
1 parent fdb7f29 commit d912b71
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/core/modules/impl/WarpGatewayInteractionsLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class WarpGatewayInteractionsLoader implements InteractionsLoader {
this.logger.debug('Loading interactions: for ', { contractId, fromSortKey, toSortKey });

const interactions: GQLNodeInterface[] = [];
let page = 0;
let page = 1;
let limit = 0;
let items = 0;
const pagesPerBatch = evaluationOptions?.transactionsPagesPerBatch || Number.MAX_SAFE_INTEGER;
Expand All @@ -97,7 +97,6 @@ export class WarpGatewayInteractionsLoader implements InteractionsLoader {
...(this._warp.whoAmI ? { client: this._warp.whoAmI } : ''),
...(fromSortKey ? { from: fromSortKey } : ''),
...(toSortKey ? { to: toSortKey } : ''),
page: (++page).toString(),
fromSdk: 'true',
...(this.confirmationStatus && this.confirmationStatus.confirmed
? { confirmationStatus: 'confirmed' }
Expand All @@ -114,6 +113,8 @@ export class WarpGatewayInteractionsLoader implements InteractionsLoader {
interactions.push(...response.interactions);
limit = response.paging.limit;
items = response.paging.items;
fromSortKey = interactions[interactions.length - 1]?.sortKey;
page++;

this.logger.debug(`Loaded interactions length: ${interactions.length}, from: ${fromSortKey}, to: ${toSortKey}`);
} while (items == limit && page < pagesPerBatch); // note: items < limit means that we're on the last page
Expand Down

0 comments on commit d912b71

Please sign in to comment.