Skip to content

Commit e14fe2c

Browse files
committed
fix: prefer a higher principal_tx count bug
1 parent bf83110 commit e14fe2c

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/datastore/postgres-store.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5542,14 +5542,14 @@ export class PgDataStore
55425542
// join against `txs` to get the full transaction objects only for that page.
55435543
`
55445544
WITH stx_txs AS (
5545-
SELECT tx_id
5545+
SELECT tx_id, ${countOverColumn()}
55465546
FROM principal_stx_txs
55475547
WHERE principal = $1 AND ${blockCond}
55485548
ORDER BY block_height DESC, microblock_sequence DESC, tx_index DESC
55495549
LIMIT $2
55505550
OFFSET $3
55515551
)
5552-
SELECT ${txColumns()}, ${abiColumn()}, ${countOverColumn()}
5552+
SELECT ${txColumns()}, ${abiColumn()}, count
55535553
FROM stx_txs
55545554
INNER JOIN txs
55555555
ON (stx_txs.tx_id = txs.tx_id

src/tests/api-tests.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4933,7 +4933,7 @@ describe('api tests', () => {
49334933
const expectedResp4 = {
49344934
limit: 20,
49354935
offset: 0,
4936-
total: 5,
4936+
total: 6,
49374937
results: [
49384938
{
49394939
tx_id: '0x12340005',
@@ -5592,7 +5592,7 @@ describe('api tests', () => {
55925592
);
55935593
expect(unanchoredResult.status).toBe(200);
55945594
expect(unanchoredResult.type).toBe('application/json');
5595-
expect(JSON.parse(unanchoredResult.text).total).toEqual(50); // 60 txs up to unanchored block_height=3
5595+
expect(JSON.parse(unanchoredResult.text).total).toEqual(60); // 60 txs up to unanchored block_height=3
55965596
expect(JSON.parse(unanchoredResult.text).results.length).toEqual(50);
55975597
});
55985598

src/tests/datastore-tests.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -975,7 +975,7 @@ describe('postgres datastore', () => {
975975
atSingleBlock: false,
976976
});
977977

978-
expect(addrEResult.total).toBe(3);
978+
expect(addrEResult.total).toBe(5);
979979

980980
const mapAddrTxResults = (txs: DbTx[]) => {
981981
return txs.map(tx => ({
@@ -1129,8 +1129,8 @@ describe('postgres datastore', () => {
11291129
atSingleBlock: false,
11301130
});
11311131

1132-
expect(addrAAtBlockResult.total).toBe(3);
1133-
expect(addrAAllBlockResult.total).toBe(7);
1132+
expect(addrAAtBlockResult.total).toBe(4);
1133+
expect(addrAAllBlockResult.total).toBe(9);
11341134
});
11351135

11361136
test('pg get address asset events', async () => {

0 commit comments

Comments
 (0)