superset-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] john-bodley closed pull request #5105: [Explore][Adhoc Metrics] updating adhoc metric filtering
Date Fri, 01 Jun 2018 06:34:49 GMT
john-bodley closed pull request #5105: [Explore][Adhoc Metrics] updating adhoc metric filtering
URL: https://github.com/apache/incubator-superset/pull/5105
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/superset/assets/spec/javascripts/explore/components/MetricsControl_spec.jsx b/superset/assets/spec/javascripts/explore/components/MetricsControl_spec.jsx
index 5d2e1e3342..9aa553ca88 100644
--- a/superset/assets/spec/javascripts/explore/components/MetricsControl_spec.jsx
+++ b/superset/assets/spec/javascripts/explore/components/MetricsControl_spec.jsx
@@ -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();
 
diff --git a/superset/assets/src/explore/components/controls/MetricsControl.jsx b/superset/assets/src/explore/components/controls/MetricsControl.jsx
index b7ed1f205d..bc0b72a4da 100644
--- a/superset/assets/src/explore/components/controls/MetricsControl.jsx
+++ b/superset/assets/src/explore/components/controls/MetricsControl.jsx
@@ -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) {
diff --git a/superset/assets/src/explore/constants.js b/superset/assets/src/explore/constants.js
index 7b57cbaa76..d5dce01998 100644
--- a/superset/assets/src/explore/constants.js
+++ b/superset/assets/src/explore/constants.js
@@ -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;


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Mime
View raw message