aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/overview/helpers/metrics.js
blob: 4b289bc36118d1dd7d72df9ea19beff72ad05b21 (plain)
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
29
30
31
32
33
34
35
36
37
38
39
40
function hasRightDomain (metric, domains) {
  return domains.indexOf(metric.domain) !== -1;
}

function isNotHidden (metric) {
  return !metric.hidden;
}

function hasSimpleType (metric) {
  return metric.type !== 'DATA' && metric.type !== 'DISTRIB';
}

function isNotDifferential (metric) {
  return metric.key.indexOf('new_') !== 0;
}

export function filterMetrics (metrics) {
  return metrics.filter(metric => {
    return isNotHidden(metric) && hasSimpleType(metric) && isNotDifferential(metric);
  });
}

export function filterMetricsForDomains (metrics, domains) {
  return filterMetrics(metrics).filter(metric => hasRightDomain(metric, domains));
}


export function getShortType (type) {
  if (type === 'INT') {
    return 'SHORT_INT';
  } else if (type === 'WORK_DUR') {
    return 'SHORT_WORK_DUR';
  }
  return type;
}


export function getMetricName (metricKey) {
  return window.t('overview.metric', metricKey);
}