Fixing time comparison to look for past deltas #7616
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
CATEGORY
Choose one
SUMMARY
On a line chart using the advanced analytics with time shift 1 year incorrectly evaluates to 366 days as the delta and as a result shows incorrect data.
parse_human_timedelta
looks forward in time when evaluating the human timedelta to number of days, but it's used in time compare to look back in time and compare current points to a previous delta. Around leap years the number of days 1 year ahead is not the same as 1 year behind. More details of the issue are in #7311I'm keeping parse_human_timedelta the way it is and adding another function to specify that we want the past delta (so
-1 year
if we are given1 year
), and returning a positive timedelta as we were previously. I looked into just making parse_human_timedelta return a negative delta, but it makes the logic in viz.py look a bit more confusing with delta =+ parse_human_timedelta(...) when it would actually be subtracting the negative delta.NOTE: This will change the data for time shift (1 year, 1 month,...) but it will be accurate.
TEST PLAN
ADDITIONAL INFORMATION
REVIEWERS
@john-bodley @mistercrunch @betodealmeida