updating adhoc metric filtering (#5105)
This commit is contained in:
parent
556ef44fac
commit
cc0942ac98
|
|
@ -211,8 +211,8 @@ describe('MetricsControl', () => {
|
|||
|
||||
expect(!!wrapper.instance().selectFilterOption(
|
||||
{
|
||||
metric_name: 'a_metric',
|
||||
optionName: 'a_metric',
|
||||
metric_name: 'avg__metric',
|
||||
optionName: 'avg__metric',
|
||||
expression: 'AVG(metric)',
|
||||
},
|
||||
'a',
|
||||
|
|
@ -238,14 +238,27 @@ describe('MetricsControl', () => {
|
|||
|
||||
expect(!!wrapper.instance().selectFilterOption(
|
||||
{
|
||||
metric_name: 'a_metric',
|
||||
optionName: 'a_metric',
|
||||
metric_name: 'avg__metric',
|
||||
optionName: 'avg__metric',
|
||||
expression: 'AVG(metric)',
|
||||
},
|
||||
'a',
|
||||
)).to.be.false;
|
||||
});
|
||||
|
||||
it('includes custom made simple saved metrics', () => {
|
||||
const { wrapper } = setup();
|
||||
|
||||
expect(!!wrapper.instance().selectFilterOption(
|
||||
{
|
||||
metric_name: 'my_fancy_sum_metric',
|
||||
optionName: 'my_fancy_sum_metric',
|
||||
expression: 'SUM(value)',
|
||||
},
|
||||
'sum',
|
||||
)).to.be.true;
|
||||
});
|
||||
|
||||
it('excludes auto generated metrics', () => {
|
||||
const { wrapper } = setup();
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import savedMetricType from '../../propTypes/savedMetricType';
|
|||
import adhocMetricType from '../../propTypes/adhocMetricType';
|
||||
import {
|
||||
AGGREGATES,
|
||||
sqlaAutoGeneratedMetricRegex,
|
||||
sqlaAutoGeneratedMetricNameRegex,
|
||||
druidAutoGeneratedMetricRegex,
|
||||
} from '../../constants';
|
||||
|
||||
|
|
@ -210,7 +210,7 @@ export default class MetricsControl extends React.PureComponent {
|
|||
if (this.props.datasourceType === 'druid') {
|
||||
return druidAutoGeneratedMetricRegex.test(savedMetric.verbose_name);
|
||||
}
|
||||
return sqlaAutoGeneratedMetricRegex.test(savedMetric.expression);
|
||||
return sqlaAutoGeneratedMetricNameRegex.test(savedMetric.metric_name);
|
||||
}
|
||||
|
||||
selectFilterOption(option, filterValue) {
|
||||
|
|
|
|||
|
|
@ -32,5 +32,6 @@ export const HAVING_OPERATORS = [
|
|||
];
|
||||
export const MULTI_OPERATORS = [OPERATORS.in, OPERATORS['not in']];
|
||||
|
||||
export const sqlaAutoGeneratedMetricNameRegex = /^(sum|min|max|avg|count|count_distinct)__.*$/i;
|
||||
export const sqlaAutoGeneratedMetricRegex = /^(LONG|DOUBLE|FLOAT)?(SUM|AVG|MAX|MIN|COUNT)\([A-Z0-9_."]*\)$/i;
|
||||
export const druidAutoGeneratedMetricRegex = /^(LONG|DOUBLE|FLOAT)?(SUM|MAX|MIN|COUNT)\([A-Z0-9_."]*\)$/i;
|
||||
|
|
|
|||
Loading…
Reference in New Issue