Adding limit parameter to view all block details
This commit is contained in:
parent
93656ec2e8
commit
b4f65f0d72
@ -702,7 +702,7 @@ async def getLatestTransactionDetails():
|
|||||||
tx_parsed_details['transactionDetails']['blockheight'] = int(item[2])
|
tx_parsed_details['transactionDetails']['blockheight'] = int(item[2])
|
||||||
tempdict.append(tx_parsed_details)
|
tempdict.append(tx_parsed_details)
|
||||||
else:
|
else:
|
||||||
c.execute('''SELECT * FROM latestTransactions WHERE blockNumber IN (SELECT DISTINCT blockNumber FROM latestTransactions 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 100) ORDER BY id ASC;''')
|
||||||
latestTransactions = c.fetchall()
|
latestTransactions = c.fetchall()
|
||||||
c.close()
|
c.close()
|
||||||
tempdict = []
|
tempdict = []
|
||||||
@ -719,13 +719,21 @@ async def getLatestTransactionDetails():
|
|||||||
|
|
||||||
@app.route('/api/v1.0/getLatestBlockDetails', methods=['GET'])
|
@app.route('/api/v1.0/getLatestBlockDetails', methods=['GET'])
|
||||||
async def getLatestBlockDetails():
|
async def getLatestBlockDetails():
|
||||||
|
|
||||||
|
limit = request.args.get('limit')
|
||||||
|
int(limit)
|
||||||
|
|
||||||
dblocation = dbfolder + '/latestCache.db'
|
dblocation = dbfolder + '/latestCache.db'
|
||||||
if os.path.exists(dblocation):
|
if os.path.exists(dblocation):
|
||||||
conn = sqlite3.connect(dblocation)
|
conn = sqlite3.connect(dblocation)
|
||||||
c = conn.cursor()
|
c = conn.cursor()
|
||||||
else:
|
else:
|
||||||
return 'Latest transactions db doesn\'t exist. This is unusual, please report on https://github.com/ranchimall/ranchimallflo-api'
|
return 'Latest transactions db doesn\'t exist. This is unusual, please report on https://github.com/ranchimall/ranchimallflo-api'
|
||||||
c.execute('''SELECT * FROM ( SELECT * FROM latestBlocks ORDER BY blockNumber DESC LIMIT 4) ORDER BY id ASC;''')
|
|
||||||
|
if limit is None:
|
||||||
|
c.execute('''SELECT * FROM ( SELECT * FROM latestBlocks ORDER BY blockNumber DESC LIMIT 4) ORDER BY id ASC;''')
|
||||||
|
else:
|
||||||
|
c.execute('SELECT * FROM ( SELECT * FROM latestBlocks ORDER BY blockNumber DESC LIMIT {}) ORDER BY id ASC;'.format(limit))
|
||||||
latestBlocks = c.fetchall()
|
latestBlocks = c.fetchall()
|
||||||
c.close()
|
c.close()
|
||||||
tempdict = []
|
tempdict = []
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user