<commit_before>import { createStore, applyMiddleware, combineReducers } from 'redux';
import thunk from 'redux-thunk';
import createLogger from 'redux-logger';
import reducers from './reducers';
import threadDispatcher from '../common/thread-middleware';
import handleMessages from '../common/message-handler';
import messages from './messages-content';

/**
 * Isolate the store creation into a function, so that it can be used outside of the
 * app's execution context, e.g. for testing.
 * @return {object} Redux store.
 */
export default function initializeStore() {
  const summaryWorker = new Worker('summary-worker.js');
  const dateGraphWorkers = [0,1,2,3].map(_ => new Worker('date-graph-worker.js'));

  const store = createStore(
    combineReducers(Object.assign({}, reducers)),
    applyMiddleware(...[
      thunk,
      threadDispatcher(summaryWorker, 'toSummaryWorker'),
      threadDispatcher(dateGraphWorkers[0], 'toDateGraphWorker'),
      threadDispatcher(dateGraphWorkers[1], 'toDateGraphWorker'),
      threadDispatcher(dateGraphWorkers[2], 'toDateGraphWorker'),
      threadDispatcher(dateGraphWorkers[3], 'toDateGraphWorker'),
      process.env.NODE_ENV === 'development'
        ? createLogger({titleFormatter: action => `content action ${action.type}`})
        : null,
    ].filter(fn => fn)));

  handleMessages(summaryWorker, store, messages);
  handleMessages(dateGraphWorkers[0], store, messages);
  handleMessages(dateGraphWorkers[1], store, messages);
  handleMessages(dateGraphWorkers[2], store, messages);
  handleMessages(dateGraphWorkers[3], store, messages);

  dateGraphWorkers.forEach((worker, i) => {
    worker.postMessage({
      type: 'SET_WORKER_INFORMATION',
      workerIndex: i,
      numWorkers: dateGraphWorkers.length,
    });
  });

  return store;
}
<commit_msg>Reduce number of date graph workers<commit_after>import { createStore, applyMiddleware, combineReducers } from 'redux';
import thunk from 'redux-thunk';
import createLogger from 'redux-logger';
import reducers from './reducers';
import threadDispatcher from '../common/thread-middleware';
import handleMessages from '../common/message-handler';
import messages from './messages-content';

/**
 * Isolate the store creation into a function, so that it can be used outside of the
 * app's execution context, e.g. for testing.
 * @return {object} Redux store.
 */
export default function initializeStore() {
  const summaryWorker = new Worker('summary-worker.js');
  const dateGraphWorkers = [0].map(_ => new Worker('date-graph-worker.js'));

  const store = createStore(
    combineReducers(Object.assign({}, reducers)),
    applyMiddleware(...[
      thunk,
      threadDispatcher(summaryWorker, 'toSummaryWorker'),
      threadDispatcher(dateGraphWorkers[0], 'toDateGraphWorker'),
      process.env.NODE_ENV === 'development'
        ? createLogger({titleFormatter: action => `content action ${action.type}`})
        : null,
    ].filter(fn => fn)));

  handleMessages(summaryWorker, store, messages);
  handleMessages(dateGraphWorkers[0], store, messages);

  dateGraphWorkers.forEach((worker, i) => {
    worker.postMessage({
      type: 'SET_WORKER_INFORMATION',
      workerIndex: i,
      numWorkers: dateGraphWorkers.length,
    });
  });

  return store;
}

{'fraction_non_alphanumeric': 0.1323170731707317, 'fraction_numerical': 0.004573170731707317, 'mean_word_length': 4.570458404074703, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '4710495', 'n_tokens_mistral': 944, 'n_tokens_neox': 926, 'n_words': 234}