Create stacked pools historical hashrates to see dominance over time

This commit is contained in:
nymkappa
2022-02-24 16:55:18 +09:00
parent a214c5ca20
commit 78fa3e33cd
16 changed files with 485 additions and 38 deletions

View File

@@ -49,6 +49,22 @@ class PoolsRepository {
return <PoolInfo[]>rows;
}
/**
* Get basic pool info and block count between two timestamp
*/
public async $getPoolsInfoBetween(from: number, to: number): Promise<PoolInfo[]> {
let query = `SELECT COUNT(height) as blockCount, pools.id as poolId, pools.name as poolName
FROM pools
LEFT JOIN blocks on pools.id = blocks.pool_id AND blocks.blockTimestamp BETWEEN FROM_UNIXTIME(?) AND FROM_UNIXTIME(?)
GROUP BY pools.id`;
const connection = await DB.pool.getConnection();
const [rows] = await connection.query(query, [from, to]);
connection.release();
return <PoolInfo[]>rows;
}
/**
* Get mining pool statistics for one pool
*/