This is an automated email from the ASF dual-hosted git repository. johnbodley pushed a commit to branch feature--embeddable-charts-pilot in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
commit 8c5e1a6762b569ab8a65683fb19d5a5dd4fb3dec Author: Conglei Shi <[email protected]> AuthorDate: Fri Dec 14 13:06:07 2018 -0800 fixed metric format --- superset/viz.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/superset/viz.py b/superset/viz.py index 8b57b6c..4aef85d 100644 --- a/superset/viz.py +++ b/superset/viz.py @@ -108,11 +108,6 @@ class BaseViz(object): label = self.get_metric_label(o) if isinstance(o, dict): o['label'] = label - else: - o = { - 'label': o, - 'expressionType': 'BUILTIN', - } self.metric_dict[label] = o # Cast to list needed to return serializable object in py3 @@ -205,6 +200,20 @@ class BaseViz(object): if not query_obj: return None + metrics = query_obj.get('metrics') + formatted_metrics = [] + for metric in metrics: + if not isinstance(metric, dict): + metric = { + 'label': metric, + 'expressionType': 'BUILTIN', + } + formatted_metrics.append(metric) + query_obj.update({ + 'metrics': formatted_metrics, + }) + + self.error_msg = '' timestamp_format = None
