<commit_before>import fetch from 'isomorphic-fetch'

export const REQUEST_ENTITIES = 'REQUEST_ENTITIES'
export const RECEIVE_ENTITIES = 'RECEIVE_ENTITIES'

function requestEntities() {
  return {
    type: REQUEST_ENTITIES
  }
}

function receiveEntities(json) {
  return {
    type: RECEIVE_ENTITIES,
    data: json.data,
    receivedAt: Date.now()
  }
}

export function fetchEntities(model, searchTerm, delay = 0) {
  return (dispatch, getState) => {
    const request = () => {
      dispatch(requestEntities())
      fetch(`http://localhost:8080/nice2/rest/entities/${model}?_search=${searchTerm}`)
        .then(response => response.json())
        .then(json => dispatch(receiveEntities(json)))
    }
    if (delay > 0) {
      setTimeout(() => {
        if (getState().list.searchTerm === searchTerm) {
          request()
        }
      }, delay)
    } else {
      request()
    }
  }
}

const ACTION_HANDLERS = {
  [RECEIVE_ENTITIES]: (state, { data }) => {
    return [].concat(data);
  }
}

const initialState = []

export default function listReducer(state = initialState, action: Action) {
  const handler = ACTION_HANDLERS[action.type]
  return handler ? handler(state, action) : state
}
<commit_msg>Include credentials when entity search request is sent<commit_after>import fetch from 'isomorphic-fetch'

export const REQUEST_ENTITIES = 'REQUEST_ENTITIES'
export const RECEIVE_ENTITIES = 'RECEIVE_ENTITIES'

function requestEntities() {
  return {
    type: REQUEST_ENTITIES
  }
}

function receiveEntities(json) {
  return {
    type: RECEIVE_ENTITIES,
    data: json.data,
    receivedAt: Date.now()
  }
}

export function fetchEntities(model, searchTerm, delay = 0) {
  return (dispatch, getState) => {
    const request = () => {
      dispatch(requestEntities())
      fetch(`http://localhost:8080/nice2/rest/entities/${model}?_search=${searchTerm}`, {
        credentials: 'include'
      })
        .then(response => response.json())
        .then(json => dispatch(receiveEntities(json)))
    }
    if (delay > 0) {
      setTimeout(() => {
        if (getState().list.searchTerm === searchTerm) {
          request()
        }
      }, delay)
    } else {
      request()
    }
  }
}

const ACTION_HANDLERS = {
  [RECEIVE_ENTITIES]: (state, { data }) => {
    return [].concat(data);
  }
}

const initialState = []

export default function listReducer(state = initialState, action: Action) {
  const handler = ACTION_HANDLERS[action.type]
  return handler ? handler(state, action) : state
}

{'fraction_non_alphanumeric': 0.1350814461660707, 'fraction_numerical': 0.0055621771950735005, 'mean_word_length': 3.2533783783783785, 'pattern_counts': {'":': 0, '<': 3, '<?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': '7636626', 'n_tokens_mistral': 807, 'n_tokens_neox': 805, 'n_words': 165}