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

Switch from numeral to numbro #6344

Merged
merged 1 commit into from
Aug 15, 2023
Merged

Conversation

eradman
Copy link
Collaborator

@eradman eradman commented Aug 2, 2023

numeraljs is no longer maintained, and incorrectly parses high-precision floats (such as 1.2e-7) as NaN.

What type of PR is this?

  • Bug Fix

Description

How is this tested?

  • viz-lib yarn tests
  • manually

Mobile & Desktop Screenshots/Recordings (if there are UI changes)

Current behavior using numeral.js

redash_float_number_numbro

New behavior using numbro.js

redash_float_number_numeral

@codecov
Copy link

codecov bot commented Aug 2, 2023

Codecov Report

Merging #6344 (53bab51) into master (acf77f8) will increase coverage by 0.03%.
Report is 5 commits behind head on master.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #6344      +/-   ##
==========================================
+ Coverage   60.74%   60.78%   +0.03%     
==========================================
  Files         153      153              
  Lines       12513    12527      +14     
  Branches     1695     1701       +6     
==========================================
+ Hits         7601     7614      +13     
- Misses       4686     4687       +1     
  Partials      226      226              

see 3 files with indirect coverage changes

@eradman
Copy link
Collaborator Author

eradman commented Aug 2, 2023

Frontend tests failed:

  1. numbers formatted without commas
  2. percent is off by 100

@justinclift
Copy link
Member

You ok to fix those? 😄

@eradman
Copy link
Collaborator Author

eradman commented Aug 2, 2023

I should be able to figure it out. Probably a difference in the interface for specifying number format

The broken tests were run by cd viz-lib && yarn test, which I mistakenly thought yarn test covered

@justinclift
Copy link
Member

The broken tests were run by cd viz-lib && yarn test, which I mistakenly thought yarn test covered

Oh. That's news to me too. Learning something every day I guess. 😄

@eradman
Copy link
Collaborator Author

eradman commented Aug 3, 2023

I fixed most of the tests. The failing tests are complaining about incorrect tooltips on the counter widgets

    -   "targetValueTooltip": "24,484,000",
    +   "targetValueTooltip": "24484000",

The tooltips do seem to be formatted correctly when I run a development server. I'll investigate further next week

@justinclift
Copy link
Member

Awesome. Sounds like it's almost across the line. 😄

@eradman
Copy link
Collaborator Author

eradman commented Aug 4, 2023

I have not stumbled across any problems while testing this manually, but this change is affects a very hot code path (parsing all numbers returned by the database, and all the number formatting for tables). We should keep poking at this for at least a week.

@justinclift
Copy link
Member

We should keep poking at this for at least a week.

Sounds sensible. 😄

@eradman
Copy link
Collaborator Author

eradman commented Aug 7, 2023

Found and fixed an off-by-100 error

Unfortunately touching one more line of code tripped the code coverage warning 🙄

numeraljs is no longer maintained, and incorrectly parses high-precision
floats (such as 1.2e-7) as NaN.
@eradman
Copy link
Collaborator Author

eradman commented Aug 14, 2023

I have tested a variety of queries and dashboards, so far it's looking good.

I'll aim to merge this tomorrow (August 15) unless someone has additional comments or concerns.

@justinclift
Copy link
Member

Sounds good to me. 😄

@eradman eradman merged commit f8934b8 into getredash:master Aug 15, 2023
12 checks passed
@eradman eradman deleted the number-format branch August 15, 2023 11:59
eradman pushed a commit to eradman/redash that referenced this pull request Nov 14, 2023
This reverts commit f8934b8.

Using a format string of '0' does not round to the nearest integer in Numbro
BenjaminVanRyseghem/numbro#745
guidopetri added a commit that referenced this pull request Nov 25, 2023
This reverts commit f8934b8.

Using a format string of '0' does not round to the nearest integer in Numbro
BenjaminVanRyseghem/numbro#745

Co-authored-by: github-actions <[email protected]>
Co-authored-by: Guido Petri <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants