add top 5 amount share and transactions for 80% of amount to value metric in insights explorer

This commit is contained in:
MaysWind
2026-04-15 00:45:59 +08:00
parent 53702e68d8
commit 50472d437a
4 changed files with 57 additions and 23 deletions
+26
View File
@@ -917,6 +917,32 @@ export const useExplorersStore = defineStore('explorers', () => {
} else {
value = 0;
}
} else if (valueMetric === TransactionExplorerValueMetric.SourceTop5AmountShare) {
if (allSourceAmountsInDefaultCurrency.length > 0) {
allSourceAmountsInDefaultCurrency.sort((a, b) => a - b);
const top5AmountSum = sumMaxN(allSourceAmountsInDefaultCurrency, 5, item => item);
value = totalSourceAmountSumInDefaultCurrency > 0 ? 100.0 * top5AmountSum / totalSourceAmountSumInDefaultCurrency : 0;
} else {
value = 0;
}
} else if (valueMetric === TransactionExplorerValueMetric.TransactionsForEightyPercentOfSourceAmount) {
if (allSourceAmountsInDefaultCurrency.length > 0) {
allSourceAmountsInDefaultCurrency.sort((a, b) => a - b);
const eightyPercentAmountThreshold: number = 0.8 * totalSourceAmountSumInDefaultCurrency;
let cumulativeAmount: number = 0;
let cumulativeCount: number = 0;
for (const amount of reversed(allSourceAmountsInDefaultCurrency)) {
cumulativeAmount += amount;
cumulativeCount++;
if (cumulativeAmount >= eightyPercentAmountThreshold) {
value = 100.0 * cumulativeCount / allSourceAmountsInDefaultCurrency.length;
break;
}
}
} else {
value = 0;
}
} else if (valueMetric === TransactionExplorerValueMetric.SourceAmountMaximum) {
value = maximumSourceAmountInDefaultCurrency === Number.MIN_SAFE_INTEGER ? 0 : maximumSourceAmountInDefaultCurrency;
} else if (valueMetric === TransactionExplorerValueMetric.SourceAmountRange) {