mirror of
https://github.com/apache/superset.git
synced 2026-04-22 17:45:21 +00:00
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:
committed by
GitHub
parent
5c98f5642b
commit
ed9867c0cc
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user