Skip to content

Commit

Permalink
change Avg_hashrate
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaolin1579 committed Sep 18, 2024
1 parent 938c1d1 commit 0b1014e
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/Miningcore/Persistence/Postgres/Repositories/StatsRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -320,19 +320,19 @@ public async Task<MinerWorkerPerformanceStats[]> PagePoolMinersByHashrateAsync(I
const string query =
@"WITH tmp AS
(
SELECT
ms.miner,
ms.hashrate,
ms.sharespersecond,
ROW_NUMBER() OVER(PARTITION BY ms.miner ORDER BY ms.hashrate DESC) AS rk
FROM (SELECT miner, SUM(hashrate) AS hashrate, SUM(sharespersecond) AS sharespersecond
FROM minerstats
WHERE poolid = @poolid AND created >= @from GROUP BY miner, created) ms
SELECT
ms.miner,
AVG(ms.hashrate) AS avg_hashrate,
AVG(ms.sharespersecond) AS avg_sharespersecond,
ROW_NUMBER() OVER(PARTITION BY ms.miner ORDER BY AVG(ms.hashrate) DESC) AS rk
FROM minerstats ms
WHERE ms.poolid = @poolid AND ms.created >= @from
GROUP BY ms.miner
)
SELECT t.miner, t.hashrate, t.sharespersecond
SELECT t.miner, t.avg_hashrate AS hashrate, t.avg_sharespersecond AS sharespersecond
FROM tmp t
WHERE t.rk = 1
ORDER by t.hashrate DESC
ORDER BY t.avg_hashrate DESC
OFFSET @offset FETCH NEXT @pageSize ROWS ONLY";

return (await con.QueryAsync<Entities.MinerWorkerPerformanceStats>(new CommandDefinition(query,
Expand Down

0 comments on commit 0b1014e

Please sign in to comment.