Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: bug with total being 0 on offset > total #2179

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/datastore/pg-store-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ export class PgStoreV2 extends BasePgStoreModule {
LIMIT ${limit}
OFFSET ${offset}
`;
const total = resultQuery.length > 0 ? resultQuery[0].count : 0;
const total = resultQuery[0].count;
const parsed = resultQuery.map(r => parseAccountTransferSummaryTxQueryResult(r));
return {
total,
Expand Down Expand Up @@ -958,8 +958,8 @@ export class PgStoreV2 extends BasePgStoreModule {
COUNT(*) OVER()::int AS total
FROM pox_sets ps
INNER JOIN combined_stackers cs ON ps.signing_key = cs.signer_key
WHERE ps.canonical = TRUE
AND ps.cycle_number = ${cycleNumber}
WHERE ps.canonical = TRUE
AND ps.cycle_number = ${cycleNumber}
AND ps.signing_key = ${signerKey}
ORDER BY locked DESC
LIMIT ${limit}
Expand Down
7 changes: 7 additions & 0 deletions tests/api/address.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,13 @@ describe('address tests', () => {
expect(v2Fetch1offset.type).toBe('application/json');
const v2Fetch1offsetJson = JSON.parse(v2Fetch1offset.text);
expect(v2Fetch1offsetJson.total).toBe(7);
const v2Fetch7offset = await supertest(api.server).get(
`/extended/v2/addresses/${testAddr2}/transactions?offset=7`
);
expect(v2Fetch7offset.status).toBe(200);
expect(v2Fetch7offset.type).toBe('application/json');
const v2Fetch7offsetJson = JSON.parse(v2Fetch7offset.text);
expect(v2Fetch7offsetJson.total).toBe(7);

const v2Fetch2 = await supertest(api.server).get(
`/extended/v2/addresses/${testAddr2}/transactions/${v2Fetch1Json.results[0].tx.tx_id}/events?limit=3`
Expand Down
Loading