Skip to content

Commit c0920c4

Browse files
committed
refactor: transactions query improvement
1 parent 84e0efe commit c0920c4

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

indexer/src/kadena-server/repository/infra/query-builders/transaction-query-builder.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,12 @@ export default class TransactionQueryBuilder {
364364
whereCondition = ` WHERE t.creationtime > $2 AND t.id > $3`;
365365
}
366366

367+
if (!params.after && !params.before && params.order === 'ASC') {
368+
const currentTime = 1572404687 + 1000;
369+
queryParams.push(currentTime, 1000);
370+
whereCondition = ` WHERE t.creationtime < $2 AND t.id < $3`;
371+
}
372+
367373
if (params.after) {
368374
const [creationTime, id] = params.after.split(':');
369375
queryParams.push(creationTime, id);

indexer/src/kadena-server/repository/infra/repository/transaction-db-repository.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,14 @@ export default class TransactionDbRepository implements TransactionRepository {
9494
* @returns Promise resolving to paginated transaction results
9595
*/
9696
async getTransactions(params: GetTransactionsParams) {
97-
const { after: afterEncoded, before: beforeEncoded, first, last, ...rest } = params;
97+
const {
98+
after: afterEncoded,
99+
before: beforeEncoded,
100+
isCoinbase: isCoinbaseParam,
101+
first,
102+
last,
103+
...rest
104+
} = params;
98105

99106
// Process pagination parameters
100107
const { limit, order, after, before } = getPaginationParams({
@@ -111,7 +118,7 @@ export default class TransactionDbRepository implements TransactionRepository {
111118
order,
112119
after,
113120
before,
114-
isCoinbase: rest.isCoinbase,
121+
isCoinbase: isCoinbaseParam,
115122
});
116123

117124
// Execute the query with the constructed parameters

0 commit comments

Comments
 (0)