Skip to content

Commit

Permalink
[hotfix] backward compatibility on date expressions (#3396)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mistercrunch authored Aug 30, 2017
1 parent 9676f02 commit 1fd08a5
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions superset/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 1fd08a5

Please sign in to comment.