Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing time comparison to look for past deltas #7616

Merged

Conversation

michellethomas
Copy link
Contributor

@michellethomas michellethomas commented May 30, 2019

CATEGORY

Choose one

  • Bug Fix
  • Enhancement (new features, refinement)
  • Refactor
  • Add tests
  • Build / Development Environment
  • Documentation

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 #7311

I'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 given 1 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

@codecov-io
Copy link

codecov-io commented May 30, 2019

Codecov Report

Merging #7616 into master will increase coverage by <.01%.
The diff coverage is 87.5%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #7616      +/-   ##
==========================================
+ Coverage   65.77%   65.77%   +<.01%     
==========================================
  Files         459      459              
  Lines       21911    21913       +2     
  Branches     2410     2410              
==========================================
+ Hits        14411    14413       +2     
  Misses       7379     7379              
  Partials      121      121
Impacted Files Coverage Δ
superset/utils/core.py 88.1% <100%> (+0.04%) ⬆️
superset/viz.py 71.95% <50%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5864ddc...0fa6b6b. Read the comment docs.

@michellethomas
Copy link
Contributor Author

ping @john-bodley

@michellethomas michellethomas added the !deprecated-label:bug Deprecated label - Use #bug instead label Jun 7, 2019
@michellethomas michellethomas merged commit 7a575ce into apache:master Jun 19, 2019
@michellethomas michellethomas deleted the fixing_time_shift_one_year branch June 19, 2019 17:10
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.34.0 labels Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels !deprecated-label:bug Deprecated label - Use #bug instead size/M 🚢 0.34.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Advanced Analytics time shift '1 year' not parsing correctly
4 participants