<commit_before>import fetch from 'isomorphic-fetch'

export async function fetchExchangeRates(base, target) {
  const params = {
    q: buildQuery(base, target),
    env: 'store://datatables.org/alltableswithkeys',
    format: 'json'
  }

  return fetch(`https://query.yahooapis.com/v1/public/yql?${encode(params)}`)
    .then(body => body.json())
    .then(response =>
      response.query.results.rate.reduce((result, row) => {
        result[row.id.substring(3)] = parseFloat(row['Rate'])
        return result
      }, {})
    )
}

function buildQuery(base, target) {
  const pairs = target.map(code => `${base}${code}`)<commit_msg>Fix single currency exchange rate issue<commit_after>import fetch from 'isomorphic-fetch'

export async function fetchExchangeRates(base, target) {
  const params = {
    q: buildQuery(base, target),
    env: 'store://datatables.org/alltableswithkeys',
    format: 'json'
  }

  return fetch(`https://query.yahooapis.com/v1/public/yql?${encode(params)}`)
    .then(body => body.json())
    .then(
      response =>
        response.query.results.rate.id !== undefined
          ? [response.query.results.rate]
          : response.query.results.rate
    )
    .then(rate =>
      rate.reduce((result, row) => {
        result[row.id.substring(3)] = parseFloat(row['Rate'])
        return result
      }, {})
    )
}

function buildQuery(base, target) {
  const pairs = target.map(code => `${base}${code}`)
{'fraction_non_alphanumeric': 0.16446911866759195, 'fraction_numerical': 0.002775850104094379, 'mean_word_length': 3.253687315634218, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6471250', 'n_tokens_mistral': 459, 'n_tokens_neox': 456, 'n_words': 82}