You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2018/06/20 19:41:50 UTC

[GitHub] john-bodley closed pull request #5241: [Explore] Handle empty metrics control data

john-bodley closed pull request #5241: [Explore] Handle empty metrics control data
URL: https://github.com/apache/incubator-superset/pull/5241
 
 
   

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/src/explore/components/controls/AdhocFilterControl.jsx b/superset/assets/src/explore/components/controls/AdhocFilterControl.jsx
index 3a12c2a7b3..1e88383359 100644
--- a/superset/assets/src/explore/components/controls/AdhocFilterControl.jsx
+++ b/superset/assets/src/explore/components/controls/AdhocFilterControl.jsx
@@ -215,17 +215,17 @@ export default class AdhocFilterControl extends React.Component {
       )),
     ].filter(option => option);
 
-    return options.map((option) => {
+    return options.reduce((results, option) => {
       if (option.saved_metric_name) {
-        return { ...option, filterOptionName: option.saved_metric_name };
+        results.push({ ...option, filterOptionName: option.saved_metric_name });
       } else if (option.column_name) {
-        return { ...option, filterOptionName: '_col_' + option.column_name };
+        results.push({ ...option, filterOptionName: '_col_' + option.column_name });
       } else if (option instanceof AdhocMetric) {
-        return { ...option, filterOptionName: '_adhocmetric_' + option.label };
+        results.push({ ...option, filterOptionName: '_adhocmetric_' + option.label });
       }
-      return null;
-    }).sort((a, b) => (
-      (a.saved_metric_name || a.column_name || a.label || '').localeCompare((
+      return results;
+    }, []).sort((a, b) => (
+      (a.saved_metric_name || a.column_name || a.label).localeCompare((
         b.saved_metric_name || b.column_name || b.label
       ))
     ));
diff --git a/superset/assets/src/explore/components/controls/MetricsControl.jsx b/superset/assets/src/explore/components/controls/MetricsControl.jsx
index d195cdb1ae..e93f6c1879 100644
--- a/superset/assets/src/explore/components/controls/MetricsControl.jsx
+++ b/superset/assets/src/explore/components/controls/MetricsControl.jsx
@@ -193,17 +193,16 @@ export default class MetricsControl extends React.PureComponent {
       ...props.savedMetrics,
     ];
 
-    return options.map((option) => {
+    return options.reduce((results, option) => {
       if (option.metric_name) {
-        return { ...option, optionName: option.metric_name };
+        results.push({ ...option, optionName: option.metric_name });
       } else if (option.column_name) {
-        return { ...option, optionName: '_col_' + option.column_name };
+        results.push({ ...option, optionName: '_col_' + option.column_name });
       } else if (option.aggregate_name) {
-        return { ...option, optionName: '_aggregate_' + option.aggregate_name };
+        results.push({ ...option, optionName: '_aggregate_' + option.aggregate_name });
       }
-      notify.error(`provided invalid option to MetricsControl, ${option}`);
-      return null;
-    });
+      return results;
+    }, []);
   }
 
   isAutoGeneratedMetric(savedMetric) {


 

----------------------------------------------------------------
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