From 1fd08a59123bf6333f01759c858d5af055eaaa5a Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Wed, 30 Aug 2017 11:18:23 -0700 Subject: [PATCH] [hotfix] backward compatibility on date expressions (#3396) Previously all 'since' date expression evaluated in the future like `30 days` would be reassigned to the past (now - `30 days`). It would extend to fixed dates which is a bad thing and was removed. Now we have reports and dashboards in the wild that use things like `30 days` and we'd like to not break those as we roll out the next version. This fix should allow for that. --- superset/viz.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/superset/viz.py b/superset/viz.py index b93f874a3e60a..a3d9a5a70a5ac 100644 --- a/superset/viz.py +++ b/superset/viz.py @@ -146,6 +146,13 @@ def query_obj(self): form_data.get("since") ) + # Backward compatibility hack + since_words = since.split(' ') + if ( + len(since_words) == 2 and + since_words[1] in ['days', 'years', 'hours', 'day', 'year']): + since += ' ago' + from_dttm = utils.parse_human_datetime(since) until = extra_filters.get('__to') or form_data.get("until", "now")