<commit_before>import React from 'react'
import { compose, createStore, applyMiddleware } from 'redux'
import organizerApp from '../reducers'
import thunkMiddleware from 'redux-thunk'
import { persistStore } from 'redux-persist'
import { connect, Provider } from 'react-redux'
import createRavenMiddleware from 'raven-for-redux'
import Raven from 'raven-js'
import _model from './model'
import _selectable from './select'
import _filterable from './filter'

import { connectRouter, routerMiddleware } from 'connected-react-router/immutable'
import { createBrowserHistory } from 'history'
import { getCurrentUser } from '../selectors/auth'

export const Model = _model
export const Selectable = _selectable
export const Filterable = _filterable

const composer = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose

export const history = createBrowserHistory()

export const store = createStore(
    connectRouter(history)(organizerApp),
    composer(applyMiddleware(createRavenMiddleware(Raven, {getUserContext: getCurrentUser} ), thunkMiddleware, routerMiddleware(history)))
)

export const withProvider = Component => {
    return function wrapped(props) {
        return (
            <Provider store={store}>
                <Component {...props} />
            </Provider>
        )
    }
}

export const persistor = persistStore(store)

export const withModelData = mapModelToFetch => WrappedComponent => {
    return connect()(class Fetcher extends React.PureComponent {
        componentDidMount() {
            Object.entries(mapModelToFetch(this.props)).forEach(([modelName, params]) => {
                const model = new Model(modelName)
                if (typeof(params) == 'object') {
                    this.props.dispatch(model.fetchAll(params))
                } else {
                    this.props.dispatch(model.fetchIfNeeded(params))<commit_msg>store: fetcher: also run fetch on prop update<commit_after>import React from 'react'
import { compose, createStore, applyMiddleware } from 'redux'
import organizerApp from '../reducers'
import thunkMiddleware from 'redux-thunk'
import { persistStore } from 'redux-persist'
import { connect, Provider } from 'react-redux'
import createRavenMiddleware from 'raven-for-redux'
import Raven from 'raven-js'
import _model from './model'
import _selectable from './select'
import _filterable from './filter'

import { connectRouter, routerMiddleware } from 'connected-react-router/immutable'
import { createBrowserHistory } from 'history'
import { getCurrentUser } from '../selectors/auth'

export const Model = _model
export const Selectable = _selectable
export const Filterable = _filterable

const composer = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose

export const history = createBrowserHistory()

export const store = createStore(
    connectRouter(history)(organizerApp),
    composer(applyMiddleware(createRavenMiddleware(Raven, {getUserContext: getCurrentUser} ), thunkMiddleware, routerMiddleware(history)))
)

export const withProvider = Component => {
    return function wrapped(props) {
        return (
            <Provider store={store}>
                <Component {...props} />
            </Provider>
        )
    }
}

export const persistor = persistStore(store)

export const withModelData = mapModelToFetch => WrappedComponent => {
    return connect()(class Fetcher extends React.PureComponent {
        componentDidMount() {
            this.fetch()
        }

        componentDidUpdate(prevProps) {
            if (prevProps.model != this.props.model) {
                this.fetch()
            }
        }

        fetch() {
            Object.entries(mapModelToFetch(this.props)).forEach(([modelName, params]) => {
                const model = new Model(modelName)
                if (typeof(params) == 'object') {
                    this.props.dispatch(model.fetchAll(params))
                } else {
                    this.props.dispatch(model.fetchIfNeeded(params))
{'fraction_non_alphanumeric': 0.10123084652097462, 'fraction_numerical': 0.0, 'mean_word_length': 3.3329706202393905, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 17, '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': '4192802', 'n_tokens_mistral': 1074, 'n_tokens_neox': 1054, 'n_words': 273}