<commit_before>import { CALL_API, Schemas } from '../middleware/api'

export const PICTOGRAMS_REQUEST = 'PICTOGRAMS_REQUEST'
export const PICTOGRAMS_SUCCESS = 'PICTOGRAMS_SUCCESS'
export const PICTOGRAMS_FAILURE = 'PICTOGRAMS_FAILURE'

// Fetches all keywords for pictos
// Relies on the custom API middleware defined in ../middleware/api.js.
function fetchPictograms(searchText) {
  return {
    [CALL_API]: {
      types: [ PICTOGRAMS_REQUEST, PICTOGRAMS_SUCCESS, PICTOGRAMS_FAILURE ],
      endpoint: `search/${searchText}`,
      schema: Schemas.SEARCH
    }
  }
}

export function loadPictograms(searchText) {
  return (dispatch, getState) => {
    const search = getState().entities.searchs[searchText]
    if (search) {
      return null
    }
    return dispatch(fetchPictograms(searchText))
  }
}<commit_msg>actions for pictograms with pagination<commit_after>import { CALL_API, Schemas } from '../middleware/api'

export const PICTOGRAMS_REQUEST = 'PICTOGRAMS_REQUEST'
export const PICTOGRAMS_SUCCESS = 'PICTOGRAMS_SUCCESS'
export const PICTOGRAMS_FAILURE = 'PICTOGRAMS_FAILURE'

// Fetches all keywords for pictos
// Relies on the custom API middleware defined in ../middleware/api.js.
function fetchPictograms(searchText, nextPageUrl) {
  return {
    searchText,
    [CALL_API]: {
      types: [ PICTOGRAMS_REQUEST, PICTOGRAMS_SUCCESS, PICTOGRAMS_FAILURE ],
      endpoint: nextPageUrl,
      schema: Schemas.SEARCH
    }
  }
}

export function loadPictograms(searchText, nextPage) {
  return (dispatch, getState) => {
    const {
      nextPageUrl = `search/${searchText}`,
      pageCount = 0
    } = getState().pagination.pictogramsBySearchText[searchText] || {}

    if (pageCount > 0 && !nextPage) {
      return null
    }
    return dispatch(fetchPictograms(searchText, nextPageUrl))
  }
}

{'fraction_non_alphanumeric': 0.10220994475138122, 'fraction_numerical': 0.0011049723756906078, 'mean_word_length': 4.058659217877095, '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': '5193690', 'n_tokens_mistral': 626, 'n_tokens_neox': 604, 'n_words': 129}