<commit_before>'use strict';

import moment from 'moment';

const defaultState = {
  from: moment(new Date()).startOf('day').subtract(30, 'days').toISOString(),
  to: moment(new Date()).startOf('day').toISOString()
};

export default (state=defaultState, action) => {
  switch (action.type) {
  case 'DOCS_FETCH':
    return {
      to: action.docs[0]._id,
      from: action.docs[action.docs.length - 1]._id
    };
  // TODO maybe add DOC_INSERT and DOC_DELETE cases.
  default:
    return state;
  }
};
<commit_msg>edge case error prevention when fetch returns no docs<commit_after>'use strict';

import moment from 'moment';

const defaultState = {
  from: moment(new Date()).startOf('day').subtract(30, 'days').toISOString(),
  to: moment(new Date()).startOf('day').toISOString()
};

export default (state=defaultState, action) => {
  switch (action.type) {
  case 'DOCS_FETCH':
    if (action.docs.length > 0) {
      return {
        to: action.docs[0]._id,
        from: action.docs[action.docs.length - 1]._id
      };
    } else {
      return state;
    }
  // TODO maybe add DOC_INSERT and DOC_DELETE cases.
  default:
    return state;
  }
};

{'fraction_non_alphanumeric': 0.15584415584415584, 'fraction_numerical': 0.007792207792207792, 'mean_word_length': 3.378787878787879, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '5908125', 'n_tokens_mistral': 393, 'n_tokens_neox': 380, 'n_words': 92}