bug fix on graphs

This commit is contained in:
Expand-sys 2022-12-28 10:38:14 +11:00
parent 0711cd944b
commit 12c70d975c

View file

@ -164,7 +164,7 @@ fastify.get(
log = JSON.parse(log.body); log = JSON.parse(log.body);
let graphlog = log; let graphlog = log;
if (graphlog != null) { if (graphlog != null) {
graphlog = graphlog.reverse(); //graphlog = graphlog.reverse();
} }
console.log(graphlog) console.log(graphlog)
console.log("here fuckwit") console.log("here fuckwit")
@ -173,20 +173,31 @@ fastify.get(
if (graphlog) { if (graphlog) {
for (i = 0; i < graphlog.length; i++) { for (i = 0; i < graphlog.length; i++) {
console.log(i)
console.log(graphlog[0]) if(graphlog[i].amount >= 0 ){
currentbal = parseInt(currentbal) - parseInt(graphlog[i].amount); currentbal = (parseInt(graphlog[i].amount)) + parseInt(currentbal);
if( i > 14) if( i > 14)
break break
graphdata.push([i+1, currentbal]) graphdata.push([i+1, currentbal])
} else{
currentbal = (parseInt(graphlog[i].amount)) + parseInt(currentbal);
if( i > 14)
break
graphdata.push([i+1, currentbal])
}
} }
const seconds = Math.floor(Date.now() / 1000); const seconds = Math.floor(Date.now() / 1000);
graphdata.unshift([0 , balance]) graphdata.unshift([0 , balance])
graphdata.unshift(["Transaction", "Amount"]) graphdata.unshift(["Transaction", "Amount"])
console.log(graphdata)
} else { } else {
graphlog = undefined; graphlog = undefined;
} }
@ -207,9 +218,6 @@ fastify.get(
transactionlog.push(`${log[i].counterparty} sent you ${log[i].amount} at ${date}`); transactionlog.push(`${log[i].counterparty} sent you ${log[i].amount} at ${date}`);
} }
console.log(transactionlog)
console.log(graphdata)
} }