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

More intuitive display of negative time deltas (#8274) #8276

Merged
merged 7 commits into from
Sep 22, 2019

Conversation

benvdh
Copy link
Contributor

@benvdh benvdh commented Sep 21, 2019

CATEGORY

Choose one

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

SUMMARY

This pull request changes the way negative time delta's are displayed. The default python display of a negative timedelta is rather unintuitive for a user of a dashboard. For example, -6 minutes is displayed as '-1 day, 23:54:00. This basically requires users to make time calculations in their heads to interpret the number correctly. This pull request changes the formatting to '-0:06:00' at the code level and -0 days 00:06:00 at the superset UI level to make it easier for users to interpret the time delta. More details on the issue and why this solution was chosen can be found in #8274 .

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

The data in postgres looks like this:
data_in_postgres

Before this pull request the data looks like this in superset:
data_in_superset_table_before

Afterwards it looks like this in superset:
data_in_superset_table_after

TEST PLAN

  • The unit test for base_json_conv() has been enhanced to handle timedelta's as well
  • A new function has been added in superset.utils.core named timedelta_f which is called in base_json_conv() (same module). A new test has been added to test this formatting function.

ADDITIONAL INFORMATION

REVIEWERS

@codecov-io
Copy link

codecov-io commented Sep 21, 2019

Codecov Report

Merging #8276 into master will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #8276      +/-   ##
==========================================
+ Coverage   67.72%   67.73%   +0.01%     
==========================================
  Files         451      451              
  Lines       22674    22678       +4     
  Branches     2370     2370              
==========================================
+ Hits        15355    15360       +5     
+ Misses       7182     7181       -1     
  Partials      137      137
Impacted Files Coverage Δ
superset/utils/core.py 88.57% <100%> (+0.24%) ⬆️

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 7090725...7d1eb56. Read the comment docs.

@benvdh benvdh changed the title [WIP] More intuitive display of negative time deltas (#8274) More intuitive display of negative time deltas (#8274) Sep 21, 2019
Copy link
Member

@villebro villebro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments. Also, do check out #8136 which might be relevant for you. I don't think it properly works in all charts yet, but if this is something that more people find useful I could probably work on improving support for durations.

@benvdh benvdh requested a review from villebro September 21, 2019 16:42
@benvdh
Copy link
Contributor Author

benvdh commented Sep 21, 2019

Left some comments. Also, do check out #8136 which might be relevant for you. I don't think it properly works in all charts yet, but if this is something that more people find useful I could probably work on improving support for durations.

Thanks for the quick review and helpful comments 👍 . They definitely improved the code. #8136 looks quite interesting and useful to my use case (described in the linked issue). Will play around with it when I find some time.

Copy link
Member

@villebro villebro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for not catching this last pass, but having a more verbose name might be more clear. Other than that LGTM 👍

@benvdh
Copy link
Contributor Author

benvdh commented Sep 21, 2019

@villebro I have renamed the function, but now suddenly the CI pipeline is failing on the cypress-sqllab test. This seems to be a known issue being addressed in open pull request #8215. Should we wait until this is fixed?

@benvdh benvdh requested a review from villebro September 21, 2019 19:10
@villebro
Copy link
Member

This is a known unrelated issue; I kicked off CI again.

@benvdh
Copy link
Contributor Author

benvdh commented Sep 21, 2019

This is a known unrelated issue; I kicked off CI again.

@villebro Thanks! Unfortunately, now it's the cypress-dashboard test (which passed in the previous built) with a similar unrelated timeOut issue:

 1) Dashboard top-level controls should allow chart level refresh:

     CypressError: Timed out retrying: cy.wait() timed out waiting 5000ms for the 1st request to the route: 'postJson_8_force'. No request ever occurred.

Are there anymore changes I need to make before this pull request can be approved?

Copy link
Member

@villebro villebro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I'm not an expert on negative time durations, but this might be something that should be brought to the attention of the python core devs.

@villebro villebro merged commit bc83b5f into apache:master Sep 22, 2019
@benvdh benvdh deleted the nicer-intervals branch September 23, 2019 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants