Skip to content

Commit

Permalink
Fix stats calculation for currency count (#362)
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus authored and kevva committed Jun 19, 2018
1 parent 20fec1d commit 29c6e91
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions app/renderer/swap-db.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,10 @@ class SwapDB {
const swaps = await this.getSwaps({since: timestamp});
const successfulSwaps = swaps.filter(swap => swap.status === 'completed');

const quoteCurrencies = new Set();
const tradedCurrencies = new Set();
for (const swap of successfulSwaps) {
quoteCurrencies.add(swap.quoteCurrency);
tradedCurrencies.add(swap.baseCurrency);
tradedCurrencies.add(swap.quoteCurrency);
}

let totalSwapsWorthInUsd = 0;
Expand All @@ -260,7 +261,7 @@ class SwapDB {

return {
successfulSwapCount: successfulSwaps.length,
currencyCount: quoteCurrencies.size,
currencyCount: tradedCurrencies.size,
totalSwapsWorthInUsd,
};
}
Expand Down
2 changes: 1 addition & 1 deletion app/renderer/views/Trades.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const Trades = props => (
</nav>
<div className="stats">
{stats &&
<p>In the last month you did {stats.successfulSwapCount} successful {stats.successfulSwapCount === 1 ? 'trade' : 'trades'} for {stats.currencyCount} {stats.currencyCount === 1 ? 'currency' : 'currencies'} worth {formatCurrency(stats.totalSwapsWorthInUsd)} in total</p>
<p>In the last month you did {stats.successfulSwapCount} successful {stats.successfulSwapCount === 1 ? 'trade' : 'trades'} in {stats.currencyCount} {stats.currencyCount === 1 ? 'currency' : 'currencies'} worth {formatCurrency(stats.totalSwapsWorthInUsd)} in total</p>
}
</div>
</header>
Expand Down

0 comments on commit 29c6e91

Please sign in to comment.