etr2460 commented on a change in pull request #9284: Reduce dashboard bootstrap 
payload
URL: 
https://github.com/apache/incubator-superset/pull/9284#discussion_r391312485
 
 

 ##########
 File path: superset/connectors/base/models.py
 ##########
 @@ -213,6 +230,87 @@ def data(self) -> Dict[str, Any]:
             "select_star": self.select_star,
         }
 
+    @staticmethod
+    def get_metric_name_from_metric(
+        metric: Union[str, Dict[str, Any]]
+    ) -> Optional[str]:
+        if isinstance(metric, str):
+            return metric
+
+        if isinstance(metric, dict) and metric.get("metric_name"):
+            return metric.get("metric_name")
+
+        return None
 
 Review comment:
   I think it's probably a confusion between "metrics" in form data and the 
"metric" model in Superset's backend. I think the "metrics" in form data are 
either `metric.metric_name` where `metric` is the metric model or an 
`AdHocMetric` in the JS frontend, which might not have any association with the 
metric model (i'm uncertain here). 
   
   We could probably improve this by standardizing on a single typedef/naming 
scheme and then migrating all the chart form_data, but this isn't an easy thing 
to do (and will only get harder once charts are more pluggable and we can't 
guarantee what type of data might be in form_data)

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


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to