<commit_before>import { take, put, call } from 'redux-saga/effects'
import * as actionTypes from '../constants/ActionTypes'
import * as actions from '../actions'

const axios = require('axios')

export function fetchCsvDataApi(dataSource) {
  return axios.get(dataSource).then(
    response => response
  )
  .then(
    response => ({ response }),
    error => ({ error: error.message || 'Something bad happened' })
  )
}


export default function* root() {
  while (true) {
    const { dataSource, mapping } = yield take(actionTypes.CSV_DATA_REQUEST)
    const { response, error } = yield call(fetchCsvDataApi, dataSource)

    if (response) {
      if (response.data !== '') {
        const csvData = response.data
        yield put(actions.fetchCsvDataSuccess(csvData, mapping, false))
      } else {
        yield put(actions.fetchCsvDataError('', {}, true))
      }
    } else if (error) {
      yield put(actions.fetchCsvDataError('', {}, true))
    }
  }
}<commit_msg>fork saga<commit_after>import { take, put, call, fork } from 'redux-saga/effects'
import * as actionTypes from '../constants/ActionTypes'
import * as actions from '../actions'

const axios = require('axios')

export function fetchCsvDataApi(dataSource) {
  return axios.get(dataSource).then(
    response => response
  )
  .then(
    response => ({ response }),
    error => ({ error: error.message || 'Something bad happened' })
  )
}

export function* watchForCsvDataRequest() {
  while (true) {
    const { dataSource, mapping } = yield take(actionTypes.CSV_DATA_REQUEST)
    const { response, error } = yield call(fetchCsvDataApi, dataSource)

    if (response) {
      if (response.data !== '') {
        const csvData = response.data
        yield put(actions.fetchCsvDataSuccess(csvData, mapping, false))
      } else {
        yield put(actions.fetchCsvDataError('', {}, true))
      }
    } else if (error) {
      yield put(actions.fetchCsvDataError('', {}, true))
    }
  }
}

export default function* root() {
  yield fork(watchForCsvDataRequest)
}
{'fraction_non_alphanumeric': 0.13857493857493858, 'fraction_numerical': 0.0, 'mean_word_length': 3.3504273504273505, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, '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': '2085394', 'n_tokens_mistral': 626, 'n_tokens_neox': 615, 'n_words': 153}