Display first month as well (very crude)

This commit is contained in:
Marco van Dijk 2022-04-16 18:35:36 +02:00
parent 36f32037d4
commit d7d0a859ca

View File

@ -28,6 +28,7 @@ const Tickets = (obj) => {
const thisTime = new Date(thisTicket.transactionTime * 1000); const thisTime = new Date(thisTicket.transactionTime * 1000);
const thisYear = thisTime.getFullYear(); const thisYear = thisTime.getFullYear();
const thisMonth = thisTime.getMonth(); const thisMonth = thisTime.getMonth();
console.log(thisMonth);
ticketIdx -= 1; ticketIdx -= 1;
// On a new month // On a new month
@ -91,6 +92,35 @@ const Tickets = (obj) => {
currentOrchCounter[thisIdx].sum += thisTicket.eventValue; currentOrchCounter[thisIdx].sum += thisTicket.eventValue;
} }
} }
if (currentOrchCounter.length) {
// Sort this months data
let sortedList = []
while (currentOrchCounter.length) {
let ticketIdx2 = currentOrchCounter.length - 1;
let largestIdx = 0;
let largestValue = 0;
// Find current O with most ticket wins in Eth
while (ticketIdx2 >= 0) {
const currentOrch = currentOrchCounter[ticketIdx2];
if (currentOrch.sum > largestValue) {
largestIdx = ticketIdx2;
largestValue = currentOrch.sum;
}
ticketIdx2 -= 1;
}
// Push current biggest list
sortedList.push(currentOrchCounter[largestIdx]);
// Remove from list
currentOrchCounter.splice(largestIdx, 1);
}
ticketsPerMonth.push(
{
year: currentYear,
month: currentMonth,
orchestrators: sortedList
}
);
}
setTicketsPerMonth(ticketsPerMonth); setTicketsPerMonth(ticketsPerMonth);
}, [livepeer.winningTickets]); }, [livepeer.winningTickets]);