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

ui: Adds human formatting to nanosecond based session durations #10062

Merged
merged 6 commits into from
Apr 28, 2021

Conversation

johncowen
Copy link
Contributor

@johncowen johncowen commented Apr 19, 2021

This PR adds human formatting to our nanosecond based session duration values.

The functionality makes use of the pretty-ms JS package, which also includes an option for formatting 'subMilliseconds' which in our case is useful for formatting to nanosecond precision (used by the session duration values).

We've used a new temporal service to do this, which uses the above package to format numbers only for the moment (we can add further types in a central place when needed, and there's a dev warning if you pass anything but a number to the method). The is a tiny bit of extra functionality on top for the above package:

  1. pretty-ms separates units with a space, so I split-joined the spaces out.
  2. I realized that we probably don't want to show a unit if the value is zero, therefore if the value is a zero we return a unit-less zero as a string.

Notes:

The temporal service (and helper) naming around that is 'inspired' by the t39 temporal proposal which is in Stage 3, which hopefully gives hints to anyone reading the code what it is used for and assumptions on how it could work, its also nice not to have to think about naming things.

If we get to the point that the temporal proposal has a wide enough native support and covers our use cases, we can drop the third-party package and use that from within the service instead.

Helper documentation is also added, which was also handy to use for manual 'get it working' testing, plus I 'filled out' the ember generated automated tests. I also added the default value of the session duration to our acceptance tests.

Changelog to come. I'll try and auto backport to 1.8/1.9/1.10 but off the top of my head it will probably need a little manual intervention to get it down to 1.8.

@johncowen johncowen added the theme/ui Anything related to the UI label Apr 19, 2021
@vercel vercel bot temporarily deployed to Preview – consul-ui-staging April 19, 2021 13:49 Inactive
@vercel vercel bot temporarily deployed to Preview – consul April 19, 2021 13:49 Inactive
Copy link
Contributor

@kaxcode kaxcode left a comment

Choose a reason for hiding this comment

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

:shipit:

@vercel vercel bot temporarily deployed to Preview – consul April 27, 2021 10:55 Inactive
@johncowen johncowen merged commit 345765f into master Apr 28, 2021
@johncowen johncowen deleted the ui/bugfix/session-duration-formatting branch April 28, 2021 11:12
@hc-github-team-consul-core
Copy link
Collaborator

🍒 If backport labels were added before merging, cherry-picking will start automatically.

To retroactively trigger a backport after merging, add backport labels and re-run https://circleci.com/gh/hashicorp/consul/358197.

@hc-github-team-consul-core
Copy link
Collaborator

🍒✅ Cherry pick of commit 345765f onto release/1.10.x succeeded!

hc-github-team-consul-core pushed a commit that referenced this pull request Apr 28, 2021
* ui: Adds human formatting to nanosecond based session durations
@hc-github-team-consul-core
Copy link
Collaborator

🍒❌ Cherry pick of commit 345765f onto release/1.9.x failed! Build Log

@hc-github-team-consul-core
Copy link
Collaborator

🍒❌ Cherry pick of commit 345765f onto release/1.8.x failed! Build Log

johncowen added a commit that referenced this pull request Apr 28, 2021
* ui: Adds human formatting to nanosecond based session durations
@johncowen
Copy link
Contributor Author

Little note here, I manually backported this to 1.9.x, but its pretty different in 1.8.x and in everything previous to 1.9.0 it shows the correct value just its not human formatted - so I don't think this absolutely needs to go onto 1.8

johncowen added a commit that referenced this pull request May 4, 2021
…) (#10141)

* ui: Adds human formatting to nanosecond based session durations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme/ui Anything related to the UI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants