mirror of
https://github.com/apache/superset.git
synced 2026-04-19 16:14:52 +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
@@ -3,6 +3,7 @@ import { expect } from 'chai';
|
||||
import {
|
||||
tryNumify, slugify, formatSelectOptionsForRange, d3format,
|
||||
d3FormatPreset, d3TimeFormatPreset, defaultNumberFormatter,
|
||||
mainMetric,
|
||||
} from '../../../javascripts/modules/utils';
|
||||
|
||||
describe('utils', () => {
|
||||
@@ -69,4 +70,31 @@ describe('utils', () => {
|
||||
expect(defaultNumberFormatter(-111000000)).to.equal('-111M');
|
||||
expect(defaultNumberFormatter(-0.23)).to.equal('-230m');
|
||||
});
|
||||
describe('mainMetric', () => {
|
||||
it('is null when no options', () => {
|
||||
expect(mainMetric([])).to.equal(undefined);
|
||||
expect(mainMetric(null)).to.equal(undefined);
|
||||
});
|
||||
it('prefers the "count" metric when first', () => {
|
||||
const metrics = [
|
||||
{ metric_name: 'count' },
|
||||
{ metric_name: 'foo' },
|
||||
];
|
||||
expect(mainMetric(metrics)).to.equal('count');
|
||||
});
|
||||
it('prefers the "count" metric when not first', () => {
|
||||
const metrics = [
|
||||
{ metric_name: 'foo' },
|
||||
{ metric_name: 'count' },
|
||||
];
|
||||
expect(mainMetric(metrics)).to.equal('count');
|
||||
});
|
||||
it('selects the first metric when "count" is not an option', () => {
|
||||
const metrics = [
|
||||
{ metric_name: 'foo' },
|
||||
{ metric_name: 'not_count' },
|
||||
];
|
||||
expect(mainMetric(metrics)).to.equal('foo');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user