Use 'count' as the default metric when available (#4606)

* Use 'count' as the default metric when available

Count is a much better default than the current behavior which is to use
whatever the first metric in the list happens to be.

* Addressing nits
This commit is contained in:
Maxime Beauchemin
2018-03-19 21:51:51 -07:00
committed by GitHub
parent 5c98f5642b
commit ed9867c0cc
3 changed files with 55 additions and 3 deletions

View File

@@ -259,3 +259,19 @@ export function getParam(name) {
const results = regex.exec(location.search);
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
}
export function mainMetric(metricOptions) {
// Using 'count' as default metric if it exists, otherwise using whatever one shows up first
let metric;
if (metricOptions && metricOptions.length > 0) {
metricOptions.forEach((m) => {
if (m.metric_name === 'count') {
metric = 'count';
}
});
if (!metric) {
metric = metricOptions[0].metric_name;
}
}
return metric;
}