Skip to content

Commit 93ec38d

Browse files
PJColomboluis-herasme
authored andcommitted
perf: decouple item counting logic from data fetching (#581)
* fix(api): set category filter to `ROLLUP` when the rollup filter is provided * feat(api): create blob `getCount` procedure * chore: add changeset * refactor(web): use `getCount()` procedure to retrieve total amount of blobs * chore: add changeset * feat(api): create block `getCount` procedure * chore: add changeset * fix(web): align header sleketon on blobs page view * refactor(web): use `getCount()` procedure to retrieve total amount of blocks * refactor(api): use count logic in `getAll` block procedure * feat(api): add transaction `getCount` procedure * refactor(web): use `getCount()` procedure to retrieve total amount of transactions on txs page * chore: merge changesets * refactor(web): organize query parameters by filter and pagination usage * test(api): remove rollup test
1 parent 35f2b74 commit 93ec38d

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

packages/api/src/routers/blob/getAll.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,17 @@ export const getAll = publicProcedure
4444
.use(withExpands)
4545
.output(outputSchema)
4646
.query(async ({ ctx: { filters, expands, pagination, prisma, count } }) => {
47+
let leadingOrderColumn: Prisma.BlobsOnTransactionsOrderByWithRelationInput =
48+
{
49+
blockTimestamp: filters.sort,
50+
};
51+
52+
if (filters.blockNumber) {
53+
leadingOrderColumn = {
54+
blockNumber: filters.sort,
55+
};
56+
}
57+
4758
const blockFiltersExists = filters.blockSlot || filters.blockType;
4859
const txFiltersExists =
4960
filters.transactionRollup !== undefined ||

packages/api/test/block.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ describe("Block router", async () => {
138138
from: 0,
139139
to: 9999,
140140
});
141+
141142
const { totalBlocks } = await caller.block.getCount({});
142143

143144
expect(totalBlocks).toBe(fixtures.canonicalBlocks.length);

packages/api/test/tx.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ describe("Transaction router", async () => {
9999
from: 0,
100100
to: 9999,
101101
});
102+
102103
const { totalTransactions } = await caller.tx.getCount({});
103104

104105
expect(totalTransactions).toBe(fixtures.canonicalTxs.length);

0 commit comments

Comments
 (0)