Skip to content

Commit

Permalink
currencies global stats - grouped by assets
Browse files Browse the repository at this point in the history
  • Loading branch information
jessy-bgl committed Jul 28, 2022
1 parent 3a3e803 commit 059309f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion server/src/usecases/statistics/global-statistics.usecase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const getDcasWithDailyAmount = (dcas: Dca[]) =>
const getCurrenciesGlobalStats = (dcas: Dca[]): CurrenciesGlobalStats => {
const activeDcasWithDailyAmount = getDcasWithDailyAmount(dcas);
const dcasTotalDailyAmount = getDcasTotalDailyAmount(dcas);
return _(activeDcasWithDailyAmount)
let currenciesGlobalStats = _(activeDcasWithDailyAmount)
.groupBy('pair')
.map((dca, pair) => ({
name: pair.split('/')[0],
Expand All @@ -37,6 +37,14 @@ const getCurrenciesGlobalStats = (dcas: Dca[]): CurrenciesGlobalStats => {
),
}))
.value();
currenciesGlobalStats = _(currenciesGlobalStats)
.groupBy('name')
.map((globalStats, name) => ({
name,
weight: _.sumBy(globalStats, 'weight'),
}))
.value();
return currenciesGlobalStats;
};

const getDcaGlobalStats = (dcas: Dca[]) => ({
Expand Down

0 comments on commit 059309f

Please sign in to comment.