Query changes

This commit is contained in:
shunmugam 2020-01-10 12:45:21 +05:30
parent 1578869e13
commit 48111f329c

View File

@ -375,9 +375,11 @@ const averageblockdifficulty = async() => {
async function avgBlockTime(height,proof) { async function avgBlockTime(height,proof) {
let query1 = "SELECT coalesce(avg(bb.alter), 0) as alter FROM (SELECT EXTRACT(EPOCH FROM (timestamp - LAG(timestamp) OVER (ORDER BY timestamp))) AS alter FROM blockchain_block where height > "+(height - 1440)+" AND height < "+height+" ) as bb"
let query2 = "SELECT coalesce(avg(bb.alter), 0) as alter FROM (SELECT EXTRACT(EPOCH FROM (timestamp - LAG(timestamp) OVER (ORDER BY timestamp))) AS alter FROM blockchain_block where height > "+(height - 1440)+" AND height < "+height+" and proof = '"+proof+"' ) as bb"
const blockaveragetime = await getConnection(Global.network) const blockaveragetime = await getConnection(Global.network)
.query( .query(
"SELECT coalesce(avg(bb.alter), 0) as alter FROM (SELECT EXTRACT(EPOCH FROM (timestamp - LAG(timestamp) OVER (ORDER BY timestamp))) AS alter FROM blockchain_block where height > "+(height - 1440)+" AND height < "+height+" and proof = '"+proof+"' ) as bb", query1,
) )
.catch(err_msg => { .catch(err_msg => {
return(err_msg); return(err_msg);