<commit_before>/**
 * @module react-cmf/lib/actions/settingsActions
 */
export const REQUEST_SETTINGS = 'REACT_CMF.REQUEST_SETTINGS';
export const REQUEST_KO = 'REACT_CMF.REQUEST_SETTINGS_KO';
export const REQUEST_OK = 'REACT_CMF.REQUEST_SETTINGS_OK';

export function requestSettings() {
	return {
		type: REQUEST_SETTINGS,
	};
}

export function receiveSettings(json) {
	return {
		type: REQUEST_OK,
		settings: json,
		receivedAt: Date.now(),
	};
}
export function errorWithSettings(error) {
	return {
		type: REQUEST_KO,
		error,
	};
}

/**
 * get the settings on the server and dispatch the corresponding actions
 * this should be executed during the bootstrap of the App.
 * @return {function} with the fetch process results
 */
export function fetchSettings() {
	return (dispatch) => {
		dispatch(requestSettings());
		return fetch('settings.json')
			.then((response) => response.json())
			.then((json) => {
				dispatch(receiveSettings(json));
			}, (error) => {<commit_msg>fix(fetch): Adds settings.json path argument (#48)<commit_after>/**
 * @module react-cmf/lib/actions/settingsActions
 */
export const REQUEST_SETTINGS = 'REACT_CMF.REQUEST_SETTINGS';
export const REQUEST_KO = 'REACT_CMF.REQUEST_SETTINGS_KO';
export const REQUEST_OK = 'REACT_CMF.REQUEST_SETTINGS_OK';

export function requestSettings() {
	return {
		type: REQUEST_SETTINGS,
	};
}

export function receiveSettings(json) {
	return {
		type: REQUEST_OK,
		settings: json,
		receivedAt: Date.now(),
	};
}

export function errorWithSettings(error) {
	return {
		type: REQUEST_KO,
		error,
	};
}

/**
 * get the settings on the server and dispatch the corresponding actions
 * this should be executed during the bootstrap of the App.
 * @param path Path of the settings.json file to fetch. Default 'settings.json'
 * @return {function} with the fetch process results
 */
export function fetchSettings(path = 'settings.json') {
	return (dispatch) => {
		dispatch(requestSettings());
		return fetch(path)
			.then(response => response.json())
			.then((json) => {
				dispatch(receiveSettings(json));
			}, (error) => {
{'fraction_non_alphanumeric': 0.12362768496420047, 'fraction_numerical': 0.0009546539379474941, 'mean_word_length': 4.695652173913044, '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': '7196576', 'n_tokens_mistral': 710, 'n_tokens_neox': 658, 'n_words': 175}