fix sorting by fees then stake

This commit is contained in:
Marco van Dijk 2022-04-22 01:38:03 +02:00
parent 2896325492
commit d4212e24e6

View File

@ -136,53 +136,6 @@ const WinnerMonth = (obj) => {
orchList = [...obj.data.winningTicketsReceived];
}
let sortedList = [];
if (orchList.length) {
// Sort this months data
while (orchList.length) {
let ticketIdx2 = orchList.length - 1;
let largestIdx = 0;
let largestValue = 0;
let thisVal = null;
// Find current O with most ticket wins in Eth
while (ticketIdx2 >= 0) {
const currentOrch = orchList[ticketIdx2];
thisVal = currentOrch.sum;
if (!thisVal) {
ticketIdx2 -= 1;
continue;
}
if (thisVal > largestValue) {
largestIdx = ticketIdx2;
largestValue = thisVal;
}
ticketIdx2 -= 1;
}
// Else try to sort by stake
if (!thisVal) {
ticketIdx2 = orchList.length - 1;
while (ticketIdx2 >= 0) {
const currentOrch = orchList[ticketIdx2];
thisVal = currentOrch.totalStake;
if (!thisVal) {
ticketIdx2 -= 1;
continue;
}
if (thisVal > largestValue) {
largestIdx = ticketIdx2;
largestValue = thisVal;
}
ticketIdx2 -= 1;
}
}
// Push current biggest list
sortedList.push(orchList[largestIdx]);
// Remove from list
orchList.splice(largestIdx, 1);
}
}
// Pies for earnings overview
let earningsObj;
if (obj.data.winningTicketsReceived && obj.data.winningTicketsReceived.length) {
@ -242,6 +195,66 @@ const WinnerMonth = (obj) => {
</div>;
}
let sortedList = [];
if (orchList.length) {
// Sort this months data
while (orchList.length) {
let ticketIdx2 = orchList.length - 1;
let largestIdx = 0;
let largestValue = 0;
// Find current O with most ticket wins in Eth
while (ticketIdx2 >= 0) {
const currentOrch = orchList[ticketIdx2];
let thisVal;
for (const obj of ticketList) {
if (obj.address == currentOrch.address) {
thisVal = obj.sum;
}
}
if (!thisVal) {
ticketIdx2 -= 1;
continue;
}
if (thisVal > largestValue) {
largestIdx = ticketIdx2;
largestValue = thisVal;
}
ticketIdx2 -= 1;
}
// Else try to sort by stake
if (!largestValue) {
ticketIdx2 = orchList.length - 1;
while (ticketIdx2 >= 0) {
const currentOrch = orchList[ticketIdx2];
let thisVal;
for (const obj of stakeList) {
if (obj.address == currentOrch.address) {
thisVal = obj.totalStake;
}
}
if (!thisVal) {
ticketIdx2 -= 1;
continue;
}
if (thisVal > largestValue) {
largestIdx = ticketIdx2;
largestValue = thisVal;
}
ticketIdx2 -= 1;
}
}
// Push current biggest list
sortedList.push(orchList[largestIdx]);
// Remove from list
orchList.splice(largestIdx, 1);
}
}
return (
<div className="stroke" key={obj.seed + "strok"}>
{obj.data.reactivationCount ?