From 48111f329ce89c7e2f2720dea8571f2f041a8042 Mon Sep 17 00:00:00 2001 From: shunmugam Date: Fri, 10 Jan 2020 12:45:21 +0530 Subject: [PATCH] Query changes --- server/utils/common.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server/utils/common.ts b/server/utils/common.ts index d817c9d..e9fc561 100644 --- a/server/utils/common.ts +++ b/server/utils/common.ts @@ -375,9 +375,11 @@ const averageblockdifficulty = async() => { 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) .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 => { return(err_msg);