From b906fece68bee8ccfba4d1f46da2221c37b5d0fa Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Fri, 16 Mar 2018 09:09:00 -0700 Subject: [PATCH] Move run_extra_queries outsize of BaseViz init --- superset/viz.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/superset/viz.py b/superset/viz.py index 2373d222fd3d1..0c552623258ea 100644 --- a/superset/viz.py +++ b/superset/viz.py @@ -79,8 +79,7 @@ def __init__(self, datasource, form_data, force=False): self._some_from_cache = False self._any_cache_key = None self._any_cached_dttm = None - - self.run_extra_queries() + self._extra_chart_data = None def run_extra_queries(self): """Lyfecycle method to use when more than one query is needed @@ -286,6 +285,7 @@ def cache_key(self, query_obj): def get_payload(self, query_obj=None): """Returns a payload of metadata and data""" + self.run_extra_queries() payload = self.get_df_payload(query_obj) df = payload.get('df') @@ -1119,7 +1119,6 @@ def process_data(self, df, aggregate=False): def run_extra_queries(self): fd = self.form_data time_compare = fd.get('time_compare') - self.extra_chart_data = None if time_compare: query_object = self.query_obj() delta = utils.parse_human_timedelta(time_compare) @@ -1137,15 +1136,15 @@ def run_extra_queries(self): if df2 is not None: df2[DTTM_ALIAS] += delta df2 = self.process_data(df2) - self.extra_chart_data = self.to_series( + self._extra_chart_data = self.to_series( df2, classed='superset', title_suffix='---') def get_data(self, df): df = self.process_data(df) chart_data = self.to_series(df) - if self.extra_chart_data: - chart_data += self.extra_chart_data + if self._extra_chart_data: + chart_data += self._extra_chart_data chart_data = sorted(chart_data, key=lambda x: x['key']) return chart_data