From 3e61acce0f2e14a8c18f385b05b091b0ee390f02 Mon Sep 17 00:00:00 2001 From: nagdahimanshu Date: Wed, 24 Jan 2024 17:54:41 +0100 Subject: [PATCH] :art: Code cleanup --- .../business/pendingTransactions.js | 26 ++++--------------- .../business/pendingTransactions.test.js | 1 - 2 files changed, 5 insertions(+), 22 deletions(-) diff --git a/services/blockchain-indexer/shared/dataService/business/pendingTransactions.js b/services/blockchain-indexer/shared/dataService/business/pendingTransactions.js index e1c450dae8..722e09822a 100644 --- a/services/blockchain-indexer/shared/dataService/business/pendingTransactions.js +++ b/services/blockchain-indexer/shared/dataService/business/pendingTransactions.js @@ -109,8 +109,6 @@ const validateParams = async params => { } } - if (params.sort) validatedParams.sort = params.sort; - return validatedParams; }; @@ -129,17 +127,6 @@ const getPendingTransactions = async params => { const validatedParams = await validateParams(params); - const sortComparator = sortParam => { - const sortProp = sortParam.split(':')[0]; - const sortOrder = sortParam.split(':')[1]; - - const comparator = (a, b) => - sortOrder === 'asc' - ? Number(a[sortProp] || 0) - Number(b[sortProp] || 0) - : Number(b[sortProp] || 0) - Number(a[sortProp] || 0); - return comparator; - }; - if (pendingTransactionsList.length) { // Filter according to the request params const filteredPendingTxs = pendingTransactionsList.filter( @@ -159,14 +146,11 @@ const getPendingTransactions = async params => { (!validatedParams.currentChainTransactions || !transaction.params.receivingChainID), ); - pendingTransactions.data = filteredPendingTxs - .sort(sortComparator(validatedParams.sort)) - .slice(offset, offset + limit) - .map(transaction => { - // Set the 'executionStatus' - transaction.executionStatus = TRANSACTION_STATUS.PENDING; - return transaction; - }); + pendingTransactions.data = filteredPendingTxs.slice(offset, offset + limit).map(transaction => { + // Set the 'executionStatus' + transaction.executionStatus = TRANSACTION_STATUS.PENDING; + return transaction; + }); pendingTransactions.meta = { count: pendingTransactions.data.length, diff --git a/services/blockchain-indexer/tests/unit/shared/dataservice/business/pendingTransactions.test.js b/services/blockchain-indexer/tests/unit/shared/dataservice/business/pendingTransactions.test.js index b6ac420b6f..cc8f9c12f1 100644 --- a/services/blockchain-indexer/tests/unit/shared/dataservice/business/pendingTransactions.test.js +++ b/services/blockchain-indexer/tests/unit/shared/dataservice/business/pendingTransactions.test.js @@ -70,7 +70,6 @@ describe('Test validateParams method', () => { const params = { moduleCommand: 'token:transfer', address: 'lskyvvam5rxyvbvofxbdfcupxetzmqxu22phm4yuo', - sort: 'timestamp:desc', }; const result = await validateParams(params);