From 87ed56ed54933a96d8a390d6fd0311437c9352c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hampus=20Sj=C3=B6berg?= Date: Thu, 29 Apr 2021 12:30:09 +0200 Subject: [PATCH] miners: Fix buggy percentage calculation --- frontend/pages/miners.tsx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/frontend/pages/miners.tsx b/frontend/pages/miners.tsx index bdb8ab3..22ba6cf 100644 --- a/frontend/pages/miners.tsx +++ b/frontend/pages/miners.tsx @@ -8,14 +8,14 @@ import { Content } from "../components/Content.ts"; import SiteTitle from "../components/SiteTitle.tsx"; import { useStoreState } from "../state/index.ts"; import SiteMenu from "../components/SiteMenu.tsx"; +import { Donation } from "../components/Donation.tsx"; const Table = styled.table` width: 100%; max-width: 1000px; - box-shadow: #000 3px 3px 14px; border-radius: 6px; - margin: 0 auto 100px; + margin: 0 auto 30px; border: 0; border-collapse: collapse; border-radius: 8px; @@ -72,8 +72,8 @@ interface IMinerData { export default function Miners() { const blocks = useStoreState((store) => store.blocks); - const forkName = config.fork.name; + const currentNumberOfBlocks = blocks.reduce((prev, currentBlock) => prev + +(currentBlock.signals !== undefined), 0); const miners = useMemo(() => { // We have to reverse the array as we have to check @@ -94,6 +94,7 @@ export default function Miners() { website: currBlock.minerWebsite, numBlocks: 1, }; + return prev; } prev[currBlock.miner].numBlocks++; return prev; @@ -119,7 +120,6 @@ export default function Miners() { {Object.entries(miners).map(([_, miner]) => { - console.log(miner.numBlocks / 2016); return ( @@ -130,7 +130,7 @@ export default function Miners() { )} {!miner.website && miner.name} - {((miner.numBlocks / 2016) * 100).toFixed(1)}% + {((miner.numBlocks / currentNumberOfBlocks) * 100).toFixed(1)}% {miner.signals && <>✅} {!miner.signals && <>🚫} @@ -140,6 +140,7 @@ export default function Miners() { })} + {config.donation && } );