Skip to content

Commit

Permalink
refactor: remove gubrak from transformResponseCurrencyPairs
Browse files Browse the repository at this point in the history
  • Loading branch information
achannarasappa committed Feb 18, 2021
1 parent fc807d9 commit 7db04cf
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions internal/currency/currency.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,18 @@ func transformResponseCurrencyPairs(responseQuotes []ResponseQuote, targetCurren

targetCurrencyPair := targetCurrency + targetCurrency + "=X"

currencyPairSymbols := From(responseQuotes).
Map(func(v ResponseQuote) string {
return v.Currency + targetCurrency + "=X"
}).
Uniq().
Reject(func(v string) bool {
return v == targetCurrencyPair || v == targetCurrency+"=X"
}).
Result()

return (currencyPairSymbols).([]string)
keys := make(map[string]bool)
currencyPairSymbols := make([]string, 0)

for _, responseQuote := range responseQuotes {
pair := responseQuote.Currency + targetCurrency + "=X"
if _, exists := keys[pair]; !exists && pair != targetCurrencyPair && pair != targetCurrency+"=X" {
keys[pair] = true
currencyPairSymbols = append(currencyPairSymbols, pair)
}
}

return currencyPairSymbols

}

Expand Down

0 comments on commit 7db04cf

Please sign in to comment.