<commit_before>import { Action as ReduxAction, Dispatch } from 'redux';

import { Action } from './actions';

export interface Action<T> extends ReduxAction {
  payload?: T;
  error?: Error
}

export const FAILED_APPLICATION_INFO = 'FAILED_APPLICATION_INFO';
export const FAILED_HISTORICAL_READING = 'FAILED_HISTORICAL_READING';
export const RETRIEVE_APPLICATION_INFO = 'RETRIEVE_APPLICATION_INFO';
export const RETRIEVE_HISTORICAL_READING = 'RETRIEVE_HISTORICAL_READING';
export const RETRIEVED_APPLICATION_INFO = 'RETRIEVED_APPLICATION_INFO';
export const RETRIEVED_HISTORICAL_READING = 'RETRIEVED_HISTORICAL_READING';

import * as api from './api';

const log = (name: string, error: Error) => {
    console.error(`An error occurred while ${name}: ${error.message}`);
}

export const retrieveApplicationInfo = () => {
    return async (dispatch: Dispatch<Action<any>>, getState) => {
        try {
            dispatch({ type: RETRIEVE_APPLICATION_INFO });
            const info = await api.retrieveApplicationInfo();
            dispatch({ type: RETRIEVED_APPLICATION_INFO, payload: info });
        } catch (error) {
            log('retrieving application info', error);
            dispatch({ type: FAILED_APPLICATION_INFO, error });
        }
    };
};

export const retrieveHistoricalReadings = (searchDate: Date) => {
    return async (dispatch: Dispatch<Action<any>>, getState) => {
        try {<commit_msg>Cleaner way of import libs<commit_after>import * as redux from 'redux';

import { Action } from './actions';

export interface Action<T> extends redux.Action {
  payload?: T;
  error?: Error
}

export const FAILED_APPLICATION_INFO = 'FAILED_APPLICATION_INFO';
export const FAILED_HISTORICAL_READING = 'FAILED_HISTORICAL_READING';
export const RETRIEVE_APPLICATION_INFO = 'RETRIEVE_APPLICATION_INFO';
export const RETRIEVE_HISTORICAL_READING = 'RETRIEVE_HISTORICAL_READING';
export const RETRIEVED_APPLICATION_INFO = 'RETRIEVED_APPLICATION_INFO';
export const RETRIEVED_HISTORICAL_READING = 'RETRIEVED_HISTORICAL_READING';

import * as api from './api';

const log = (name: string, error: Error) => {
    console.error(`An error occurred while ${name}: ${error.message}`);
}

export const retrieveApplicationInfo = () => {
    return async (dispatch: redux.Dispatch<Action<any>>, getState) => {
        try {
            dispatch({ type: RETRIEVE_APPLICATION_INFO });
            const info = await api.retrieveApplicationInfo();
            dispatch({ type: RETRIEVED_APPLICATION_INFO, payload: info });
        } catch (error) {
            log('retrieving application info', error);
            dispatch({ type: FAILED_APPLICATION_INFO, error });
        }
    };
};

export const retrieveHistoricalReadings = (searchDate: Date) => {
    return async (dispatch: redux.Dispatch<Action<any>>, getState) => {
        try {
{'fraction_non_alphanumeric': 0.11087645195353749, 'fraction_numerical': 0.0, 'mean_word_length': 4.2727272727272725, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 23, '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': '3356409', 'n_tokens_mistral': 896, 'n_tokens_neox': 879, 'n_words': 208}