john-bodley closed pull request #4627: Move run_extra_queries outsize of
BaseViz init
URL: https://github.com/apache/incubator-superset/pull/4627
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/viz.py b/superset/viz.py
index 2373d222fd..0c55262325 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
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services