From b8d1f32767eaa273f1eaa1437e887b99bed6d916 Mon Sep 17 00:00:00 2001 From: Vivek Teega Date: Tue, 10 Sep 2019 07:18:48 +0530 Subject: [PATCH] Select distinct blockNumber when fetching the latest transactions --- ranchimallflo_api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ranchimallflo_api.py b/ranchimallflo_api.py index 1bf7000..efa5f64 100644 --- a/ranchimallflo_api.py +++ b/ranchimallflo_api.py @@ -546,7 +546,7 @@ async def getLatestTransactionDetails(): return 'Latest transactions db doesn\'t exist. This is unusual, please report on https://github.com/ranchimall/ranchimallflo-api' if numberOfLatestBlocks is not None: - c.execute('SELECT * FROM latestTransactions WHERE blockNumber IN (SELECT blockNumber FROM latestBlocks ORDER BY blockNumber DESC LIMIT {}) ORDER BY id ASC;'.format(int(numberOfLatestBlocks))) + c.execute('SELECT * FROM latestTransactions WHERE blockNumber IN (SELECT DISTINCT blockNumber FROM latestTransactions ORDER BY blockNumber DESC LIMIT {}) ORDER BY id ASC;'.format(int(numberOfLatestBlocks))) latestTransactions = c.fetchall() c.close() tempdict = [] @@ -559,7 +559,7 @@ async def getLatestTransactionDetails(): tx_parsed_details['transactionDetails']['blockheight'] = int(item[2]) tempdict.append(tx_parsed_details) else: - c.execute('''SELECT * FROM latestTransactions WHERE blockNumber IN (SELECT blockNumber FROM latestBlocks ORDER BY blockNumber DESC LIMIT 10) ORDER BY id ASC;''') + c.execute('''SELECT * FROM latestTransactions WHERE blockNumber IN (SELECT DISTINCT blockNumber FROM latestTransactions ORDER BY blockNumber DESC LIMIT 10) ORDER BY id ASC;''') latestTransactions = c.fetchall() c.close() tempdict = []