<commit_before>import { combineReducers } from 'redux'
import createDataReducer from './dataReducer'
import createMetaReducer from './metaReducer'
import get from 'lodash.get'

const createRelationshipReducer = config => {
  const reducer = combineReducers({
    data: createDataReducer(config),
    meta: createMetaReducer(config)
  })

  return (state = {}, action) => {
    if (!action.meta) { return state }

    // alter the action before passing to reducer
    const newAction = {
      ...action,
      meta: {
        ...action.meta,
        relationshipData: state.data, // for changedData
        changedData: get(state, 'meta.changedData'), // for save
        isDeleted: get(state, 'meta.isDeleted') // for save
      }
    }
    return reducer(state, newAction)
  }
}

export default createRelationshipReducer<commit_msg>bail on key mismatch in relationship reducer<commit_after>import { combineReducers } from 'redux'
import createDataReducer from './dataReducer'
import createMetaReducer from './metaReducer'
import { selectKey } from '../../selectors/action'
import get from 'lodash.get'

const createRelationshipReducer = config => {
  const reducer = combineReducers({
    data: createDataReducer(config),
    meta: createMetaReducer(config)
  })

  return (state = {}, action) => {
    if (!action.meta) { return state }
    const actionKey = selectKey(action)
    if (actionKey !== config.key) { return state }
    // alter the action before passing to reducer
    const newAction = {
      ...action,
      meta: {
        ...action.meta,
        relationshipData: state.data, // for changedData
        changedData: get(state, 'meta.changedData'), // for save
        isDeleted: get(state, 'meta.isDeleted') // for save
      }
    }
    return reducer(state, newAction)
  }
}

export default createRelationshipReducer
{'fraction_non_alphanumeric': 0.11521739130434783, 'fraction_numerical': 0.0, 'mean_word_length': 3.1463963963963963, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '4146815', 'n_tokens_mistral': 550, 'n_tokens_neox': 532, 'n_words': 147}