[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.
This commit is contained in:
Maxime Beauchemin 2017-08-30 11:18:23 -07:00 committed by GitHub
parent 9676f02497
commit 1fd08a5912
1 changed files with 7 additions and 0 deletions

View File

@ -146,6 +146,13 @@ class BaseViz(object):
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")