All files / ee/app/assets/javascripts/issues_analytics/stores/modules/issue_analytics actions.js

90.9% Statements 10/11
100% Branches 0/0
85.71% Functions 6/7
90.9% Lines 10/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28          4x 5x     4x 1x     4x 1x   1x   1x 1x 1x              
import { createAlert } from '~/alert';
import { __ } from '~/locale';
import service from '../../../services/issue_analytics_service';
import * as types from './mutation_types';
 
export const setFilters = ({ commit }, value) => {
  commit(types.SET_FILTERS, value);
};
 
export const setLoadingState = ({ commit }, value) => {
  commit(types.SET_LOADING_STATE, value);
};
 
export const fetchChartData = ({ commit, dispatch, getters }, endpoint) => {
  dispatch('setLoadingState', true);
 
  return service
    .fetchChartData(endpoint, getters.appliedFilters)
    .then((res) => res.data)
    .then((data) => commit(types.SET_CHART_DATA, data))
    .then(() => dispatch('setLoadingState', false))
    .catch(() =>
      createAlert({
        message: __('An error occurred while loading chart data'),
      }),
    );
};