<commit_before>import * as ActionTypes from '../actions'
import { updateObject, removeByKey, updateByKey } from './reducerUtilities'

const initialState = {}

const keyMap = {
  [ActionTypes.SUM_BY]: 'sumBy',
  [ActionTypes.GROUP_BY]: 'groupBy',
  [ActionTypes.CHANGE_DATEBY]: 'dateBy',
  [ActionTypes.SELECT_COLUMN]: 'selectedColumn'
}

function updateQueryKeys (state, action) {
  return updateObject(state, {
    [keyMap[action.type]]: action.payload
  })
}

function selectColumn (state, action) {
  return updateObject(state, {
    selectedColumn: action.payload
  })
}

function dataRequest (state, action) {
  return updateObject(state, {
    isFetching: true
  })
}

function setFetchingFalse (state, action) {
  return updateObject(state, {
    isFetching: false
  })
}

function sumBy (state, action) {
  let sumKey = action.payload ? action.payload.value : null
  return updateObject(state, {
    sumBy: sumKey
  })
}

function groupBy (state, action) {
  let groupKey = action.payload ? action.payload.value : null
  return updateObject(state, {
    groupBy: groupKey
  })
}

function addFilter (state, action) {
  return updateObject(state, {
    filters: {
      [action.payload.value]: {}
    }
  })
}

function removeFilter (state, action) {
  return updateObject(state, {
    filters: removeByKey(state.filters, action.payload)
  })
}

function updateFilter (state, action) {
  return updateObject(state, {
    filters: updateByKey(state.filters, action.payload.key, action.payload)
  })
}

function resetState (state, action) {
  return initialState
}<commit_msg>fix reducer to merge multiple filters<commit_after>import * as ActionTypes from '../actions'
import { updateObject, removeByKey, updateByKey } from './reducerUtilities'
import merge from 'lodash/merge'

const initialState = {}

const keyMap = {
  [ActionTypes.SUM_BY]: 'sumBy',
  [ActionTypes.GROUP_BY]: 'groupBy',
  [ActionTypes.CHANGE_DATEBY]: 'dateBy',
  [ActionTypes.SELECT_COLUMN]: 'selectedColumn'
}

function updateQueryKeys (state, action) {
  return updateObject(state, {
    [keyMap[action.type]]: action.payload
  })
}

function selectColumn (state, action) {
  return updateObject(state, {
    selectedColumn: action.payload
  })
}

function dataRequest (state, action) {
  return updateObject(state, {
    isFetching: true
  })
}

function setFetchingFalse (state, action) {
  return updateObject(state, {
    isFetching: false
  })
}

function sumBy (state, action) {
  let sumKey = action.payload ? action.payload.value : null
  return updateObject(state, {
    sumBy: sumKey
  })
}

function groupBy (state, action) {
  let groupKey = action.payload ? action.payload.value : null
  return updateObject(state, {
    groupBy: groupKey
  })
}

function addFilter (state, action) {
  return merge({}, state, {
    filters: {
      [action.payload.value]: {}
    }
  })
}

function removeFilter (state, action) {
  return updateObject(state, {
    filters: removeByKey(state.filters, action.payload)
  })
}

function updateFilter (state, action) {
  return updateObject(state, {
    filters: updateByKey(state.filters, action.payload.key, action.payload)
  })
}

function resetState (state, action) {
  return initialState
}
{'fraction_non_alphanumeric': 0.12313432835820895, 'fraction_numerical': 0.0, 'mean_word_length': 4.222402597402597, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1525956', 'n_tokens_mistral': 1014, 'n_tokens_neox': 1021, 'n_words': 238}