<commit_before>// Thanks to: https://github.com/cloudmu/react-redux-starter-kit
import { callApi } from '../utils/api'

export const SELECT_VEHICLES_PAGE = 'SELECT_VEHICLES_PAGE'
export const INVALIDATE_VEHICLES_PAGE = 'INVALIDATE_VEHICLES_PAGE'

export const VEHICLES_REQUEST = 'VEHICLES_REQUEST'
export const VEHICLES_SUCCESS = 'VEHICLES_SUCCESS'
export const VEHICLES_FAILURE = 'VEHICLES_FAILURE'
export const VEHICLES_ADD = 'VEHICLES_ADD'

export function selectVehiclesPage(page) {
  return {
    type: SELECT_VEHICLES_PAGE,
    page,
  }
}

export function invalidateVehiclesPage(page) {
  return {
    type: INVALIDATE_VEHICLES_PAGE,
    page,
  }
}


function vehiclesRequest(page) {
  return {
    type: VEHICLES_REQUEST,
    page,
  }
}

// This is a curried function that takes page as argument,
// and expects payload as argument to be passed upon API call success.
function vehiclesSuccess(page) {
  return function (payload) {
    return {
      type: VEHICLES_SUCCESS,
      page,
      vehicles: payload.items,
      totalCount: payload.total_count,
    }
  }
}

// This is a curried function that takes page as argument,
// and expects error as argument to be passed upon API call failure.
function vehiclesFailure(page) {
  return function (error) {
    return {
      type: VEHICLES_FAILURE,
      page,
      error,
    }
  }
}

// This should come from process.env.API_URL
const API_ROOT = 'http://localhost:8080/api'
function fetchVehicles(page) {
  const url = `${API_ROOT}/vehicles/?page=${page}`
  return callApi(url, null, vehiclesRequest(page), vehiclesSuccess(page), vehiclesFailure(page))<commit_msg>add production api url<commit_after>// Thanks to: https://github.com/cloudmu/react-redux-starter-kit
import { callApi } from '../utils/api'

export const SELECT_VEHICLES_PAGE = 'SELECT_VEHICLES_PAGE'
export const INVALIDATE_VEHICLES_PAGE = 'INVALIDATE_VEHICLES_PAGE'

export const VEHICLES_REQUEST = 'VEHICLES_REQUEST'
export const VEHICLES_SUCCESS = 'VEHICLES_SUCCESS'
export const VEHICLES_FAILURE = 'VEHICLES_FAILURE'
export const VEHICLES_ADD = 'VEHICLES_ADD'

export function selectVehiclesPage(page) {
  return {
    type: SELECT_VEHICLES_PAGE,
    page,
  }
}

export function invalidateVehiclesPage(page) {
  return {
    type: INVALIDATE_VEHICLES_PAGE,
    page,
  }
}


function vehiclesRequest(page) {
  return {
    type: VEHICLES_REQUEST,
    page,
  }
}

// This is a curried function that takes page as argument,
// and expects payload as argument to be passed upon API call success.
function vehiclesSuccess(page) {
  return function (payload) {
    return {
      type: VEHICLES_SUCCESS,
      page,
      vehicles: payload.items,
      totalCount: payload.total_count,
    }
  }
}

// This is a curried function that takes page as argument,
// and expects error as argument to be passed upon API call failure.
function vehiclesFailure(page) {
  return function (error) {
    return {
      type: VEHICLES_FAILURE,
      page,
      error,
    }
  }
}

let API_ROOT = 'https://enigmatic-retreat-38913.herokuapp.com/api'
if (process.env.NODE_ENV !== 'production') {
  API_ROOT = 'http://localhost:8080/api'
}

function fetchVehicles(page) {
  const url = `${API_ROOT}/vehicles/?page=${page}`
  return callApi(url, null, vehiclesRequest(page), vehiclesSuccess(page), vehiclesFailure(page))
{'fraction_non_alphanumeric': 0.09720972097209721, 'fraction_numerical': 0.0039003900390039005, 'mean_word_length': 3.98355754857997, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 3, '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': '5251401', 'n_tokens_mistral': 1121, 'n_tokens_neox': 1099, 'n_words': 278}