mistercrunch closed pull request #5546: [bugfix] time filter on dashboard view
URL: https://github.com/apache/incubator-superset/pull/5546
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/legacy.py b/superset/legacy.py
index 25f282d4cc..54da75c93d 100644
--- a/superset/legacy.py
+++ b/superset/legacy.py
@@ -86,6 +86,6 @@ def cast_form_data(form_data):
def update_time_range(form_data):
"""Move since and until to time_range."""
- form_data['time_range'] = '{} : {}'.format(
- form_data.pop('since'), form_data.pop('until'))
- return form_data
+ if 'since' in form_data or 'until' in form_data:
+ form_data['time_range'] = '{} : {}'.format(
+ form_data.pop('since', ''), form_data.pop('until', ''))
diff --git a/superset/models/core.py b/superset/models/core.py
index 9264fcfe36..46c445274b 100644
--- a/superset/models/core.py
+++ b/superset/models/core.py
@@ -37,6 +37,7 @@
from superset import app, db, db_engine_specs, security_manager, utils
from superset.connectors.connector_registry import ConnectorRegistry
+from superset.legacy import update_time_range
from superset.models.helpers import AuditMixinNullable, ImportMixin, set_perm
from superset.viz import viz_types
install_aliases()
@@ -213,8 +214,10 @@ def form_data(self):
'datasource': '{}__{}'.format(
self.datasource_id, self.datasource_type),
})
+
if self.cache_timeout:
form_data['cache_timeout'] = self.cache_timeout
+ update_time_range(form_data)
return form_data
def get_explore_url(self, base_url='/superset/explore', overrides=None):
diff --git a/superset/views/core.py b/superset/views/core.py
index 17eb34ba87..65fa4f4d75 100755
--- a/superset/views/core.py
+++ b/superset/views/core.py
@@ -1005,6 +1005,8 @@ def get_form_data(self, slice_id=None):
slice_form_data.update(form_data)
form_data = slice_form_data
+ update_time_range(form_data)
+
return form_data, slc
def get_viz(
@@ -1311,10 +1313,6 @@ def explore(self, datasource_type=None,
datasource_id=None):
datasource_type,
datasource.name)
- # update to new time filter
- if 'since' in form_data and 'until' in form_data:
- form_data = update_time_range(form_data)
-
standalone = request.args.get('standalone') == 'true'
bootstrap_data = {
'can_add': slice_add_perm,
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]