mirror of
https://github.com/lnbits/lnbits-legend.git
synced 2025-02-24 22:58:46 +01:00
fix counting
This commit is contained in:
parent
a030b16471
commit
e39b4c3f5a
1 changed files with 11 additions and 9 deletions
|
@ -1003,16 +1003,18 @@
|
||||||
.reduce((sum, el) => (sum += el.amount), 0)
|
.reduce((sum, el) => (sum += el.amount), 0)
|
||||||
},
|
},
|
||||||
getTokenList: function () {
|
getTokenList: function () {
|
||||||
const x = this.proofs
|
console.log(this.proofs)
|
||||||
.map(t => t.amount)
|
const amounts = this.proofs.map(t => t.amount)
|
||||||
.reduce((acc, amount) => {
|
const counts = {};
|
||||||
acc[amount] = acc[amount] + amount || 1
|
|
||||||
return acc
|
for (const num of amounts) {
|
||||||
}, {})
|
counts[num] = counts[num] ? counts[num] + 1 : 1;
|
||||||
return Object.keys(x).map(k => ({
|
}
|
||||||
|
console.log("counts", counts)
|
||||||
|
return Object.keys(counts).map(k => ({
|
||||||
value: parseInt(k),
|
value: parseInt(k),
|
||||||
count: x[k],
|
count: parseInt(counts[k]),
|
||||||
sum: k * x[k]
|
sum: k * counts[k]
|
||||||
}))
|
}))
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue