Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix stats calculation for currency count #362

Merged
merged 1 commit into from
Jun 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions app/renderer/swap-db.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,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 @@ -247,7 +248,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