<commit_before>import { ADD_ENTRY, FETCH_ENTRIES } from '../constants/ActionTypes';

const initialState = [];

export default function entries(state = initialState, action) {
  switch (action.type) {
    case ADD_ENTRY:
      return [{
        id: (state.length === 0) ? 0 : state[0].id + 1,
        title: action.title,
        body: action.body
      }, ...state];
    case FETCH_ENTRIES:
      return action.entries;
    default:
      return state;
  }
}
<commit_msg>Fix adding entries<commit_after>import { ADD_ENTRY, FETCH_ENTRIES } from '../constants/ActionTypes';

const initialState = [];

export default function entries(state = initialState, action) {
  switch (action.type) {
    case ADD_ENTRY:
      // FIXME: finding the largest id is a bit of a hack right now
      return [{
        id: (state.length === 0) ? 0 : Math.max(state[0].id, state[state.length-1].id) + 1,
        title: action.title,
        body: action.body
      }, ...state];
    case FETCH_ENTRIES:
      return action.entries;
    default:
      return state;
  }
}

{'fraction_non_alphanumeric': 0.12940057088487156, 'fraction_numerical': 0.008563273073263558, 'mean_word_length': 2.627586206896552, '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': '313855', 'n_tokens_mistral': 335, 'n_tokens_neox': 331, 'n_words': 88}