Skip to content

Commit

Permalink
Adding note to updating about time_compare
Browse files Browse the repository at this point in the history
  • Loading branch information
michellethomas committed Jun 18, 2019
1 parent 41cfc28 commit 0fa6b6b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions UPDATING.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ creation of permissions set `FAB_UPDATE_PERMS = False` on config.
which adds missing non-nullable fields and uniqueness constraints to the metrics
and sql_metrics tables. Depending on the integrity of the data, manual
intervention may be required.
* [7616](https://github.com/apache/incubator-superset/pull/7616): this bug fix
changes time_compare deltas to correctly evaluate to the number of days prior
instead of number of days in the future. It will change the data for advanced
analytics time_compare so `1 year` from 5/1/2019 will be calculated as 365 days
instead of 366 days.

## Superset 0.32.0

Expand Down
7 changes: 5 additions & 2 deletions superset/utils/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,11 @@ def parse_human_timedelta(s: str) -> timedelta:
def parse_past_timedelta(delta_str: str) -> timedelta:
"""
Takes a delta like '1 year' and finds the timedelta for that period in
the past. parse_human_timedelta('-1 year') returns datetime.timedelta(-365), so
we need to return -datetime.timedelta(-365) or datetime.timedelta(365).
the past, then represents that past timedelta in positive terms.
parse_human_timedelta('1 year') find the timedelta 1 year in the future.
parse_past_timedelta('1 year') returns -datetime.timedelta(-365)
or datetime.timedelta(365).
"""
return -parse_human_timedelta(
delta_str if delta_str.startswith('-') else f'-{delta_str}')
Expand Down

0 comments on commit 0fa6b6b

Please sign in to comment.