summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/admin/statistics_panel/store/getters.js
blob: 2aa34b8f38ea3507e1f86438141be39f24d53cd4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/**
 * Merges the statisticsLabels with the state's data
 * and returns an array of the following form:
 * [{ key: "forks", label: "Forks", value: 50 }]
 */
// eslint-disable-next-line import/prefer-default-export
export const getStatistics = state => labels =>
  Object.keys(labels).map(key => {
    const result = {
      key,
      label: labels[key],
      value: state.statistics && state.statistics[key] ? state.statistics[key] : null,
    };
    return result;
  });