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

[Discover] Add long numerals support #5592

Merged

Conversation

AMoo-Miki
Copy link
Collaborator

@AMoo-Miki AMoo-Miki commented Dec 9, 2023

Description

  • Add long numerals support to Discover tabular view, document view, inspector, hash-url, and share
  • Use a fork of numeral-js that supports long numerals
  • Patch rison to correctly serialize BigInts
    Replace the uses of withLongNumerals with withLongNumeralsSupport to match the rest of the codebase and mark withLongNumerals for deprecation
  • Add withLongNumeralsSupport as an option to code/public/http/fetch
  • Add long numerals support to UiSettingsClient
  • Add long numerals support to core/server/http/router response handler
  • Add long numerals support to RangeFilter and FilterBar
  • Add long numerals support to kuery/ast
  • Introduce OPENSEARCH_SEARCH_WITH_LONG_NUMERALS_STRATEGY in core/plugins/data/search

Screenshot

Check List

  • All tests pass
    • yarn test:jest
    • yarn test:jest_integration
  • New functionality includes testing.
  • New functionality has been documented.
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

Copy link

codecov bot commented Dec 9, 2023

Codecov Report

Attention: 12 lines in your changes are missing coverage. Please review.

Comparison is base (bf5e842) 67.02% compared to head (55c47a5) 67.02%.
Report is 2 commits behind head on main.

Files Patch % Lines
src/core/server/http/router/response_adapter.ts 0.00% 1 Missing and 2 partials ⚠️
...omponents/data_grid/data_grid_table_cell_value.tsx 40.00% 2 Missing and 1 partial ⚠️
src/core/public/ui_settings/ui_settings_client.ts 50.00% 0 Missing and 1 partial ⚠️
...ns/data/common/field_formats/converters/numeral.ts 66.66% 0 Missing and 1 partial ⚠️
...c/plugins/data/public/search/search_interceptor.ts 83.33% 0 Missing and 1 partial ⚠️
...c/ui/filter_bar/filter_editor/lib/filter_label.tsx 0.00% 1 Missing ⚠️
...a/server/search/opensearch_search/decide_client.ts 50.00% 0 Missing and 1 partial ⚠️
...lic/saved_object/helpers/serialize_saved_object.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5592   +/-   ##
=======================================
  Coverage   67.02%   67.02%           
=======================================
  Files        3294     3294           
  Lines       63307    63318   +11     
  Branches    10071    10083   +12     
=======================================
+ Hits        42432    42440    +8     
- Misses      18430    18432    +2     
- Partials     2445     2446    +1     
Flag Coverage Δ
Linux_1 35.23% <6.25%> (-0.01%) ⬇️
Linux_2 55.18% <28.57%> (-0.01%) ⬇️
Linux_3 43.88% <56.09%> (+0.01%) ⬆️
Linux_4 35.33% <14.28%> (-0.01%) ⬇️
Windows_1 35.26% <6.25%> (-0.01%) ⬇️
Windows_2 55.15% <28.57%> (-0.01%) ⬇️
Windows_3 43.88% <56.09%> (+<0.01%) ⬆️
Windows_4 35.33% <14.28%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@AMoo-Miki AMoo-Miki force-pushed the fix-discover-long-numerals branch 4 times, most recently from 3c19a84 to 58f0a07 Compare December 11, 2023 22:21
@@ -58,12 +59,12 @@ export const fetchTableDataCell = (
return <span>-</span>;
}

if (!fieldInfo?.type && flattenedRow && typeof flattenedRow[columnId] === 'object') {
if (!fieldInfo?.type && typeof flattenedRow?.[columnId] === 'object') {
Copy link
Member

@kavilla kavilla Dec 12, 2023

Choose a reason for hiding this comment

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

does javascript end up equating this as undefined and null but then typeof of null equating to an object? idk if it can ever be null though.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

flattenedRow?.[columnId] would be undefined if flattenedRow was null, undefined, Boolean(false), Number(0), or "". For the last 3, the prototype props and functions can be named in columnId but then, they could be called with any Boolean, Number, or String and if we wanted to block those from being used, we would need to handle them for all of those types and not just for the falsy ones.

@AMoo-Miki AMoo-Miki force-pushed the fix-discover-long-numerals branch 2 times, most recently from 3590bed to fead6fb Compare December 15, 2023 21:52
src/core/public/http/types.ts Show resolved Hide resolved
Comment on lines +100 to +104
return type === 'number' && typeof value !== 'bigint'
? isFinite(value) && (value > Number.MAX_SAFE_INTEGER || value < Number.MIN_SAFE_INTEGER)
? BigInt(value)
: parseFloat(value)
: value;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I prefer if-else over complex ternaries for readability

BSFishy
BSFishy previously approved these changes Dec 19, 2023
CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
Signed-off-by: Miki <miki@amazon.com>
* Add long numerals support to Discover tabular view, document view, inspector, hash-url, and share
* Use a fork of `numeral-js` that supports long numerals
* Patch `rison` to correctly serialize BigInts
* Replace the uses of `withLongNumerals` with `withLongNumeralsSupport` to match the rest of the codebase and mark `withLongNumerals` for deprecation
* Add `withLongNumeralsSupport` as an option to `code/public/http/fetch`
* Add long numerals support to `UiSettingsClient`
* Add long numerals support to `core/server/http/router` response handler
* Add long numerals support to `RangeFilter` and `FilterBar`
* Add long numerals support to `kuery/ast`
* Introduce `OPENSEARCH_SEARCH_WITH_LONG_NUMERALS_STRATEGY` in `core/plugins/data/search`
* Remove `ng-non-bindable` leftovers

Signed-off-by: Miki <miki@amazon.com>
Signed-off-by: Miki <miki@amazon.com>
@AMoo-Miki AMoo-Miki merged commit 10ae4ee into opensearch-project:main Jan 10, 2024
69 of 70 checks passed
@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.x failed:

The process '/usr/bin/git' failed with exit code 128

To backport manually, run these commands in your terminal:

# Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/OpenSearch-Dashboards/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/OpenSearch-Dashboards/backport-2.x
# Create a new branch
git switch --create backport/backport-5592-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 10ae4eeceba9251bc88ad33affa8bd6d595b5206
# Push it to GitHub
git push --set-upstream origin backport/backport-5592-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/OpenSearch-Dashboards/backport-2.x

Then, create a pull request where the base branch is 2.x and the compare/head branch is backport/backport-5592-to-2.x.

AMoo-Miki added a commit to AMoo-Miki/OpenSearch-Dashboards that referenced this pull request Feb 3, 2024
* Fix the usage of `pegjs` in tasks

Signed-off-by: Miki <miki@amazon.com>

* [Discover] Add long numerals support

* Add long numerals support to Discover tabular view, document view, inspector, hash-url, and share
* Use a fork of `numeral-js` that supports long numerals
* Patch `rison` to correctly serialize BigInts
* Replace the uses of `withLongNumerals` with `withLongNumeralsSupport` to match the rest of the codebase and mark `withLongNumerals` for deprecation
* Add `withLongNumeralsSupport` as an option to `code/public/http/fetch`
* Add long numerals support to `UiSettingsClient`
* Add long numerals support to `core/server/http/router` response handler
* Add long numerals support to `RangeFilter` and `FilterBar`
* Add long numerals support to `kuery/ast`
* Introduce `OPENSEARCH_SEARCH_WITH_LONG_NUMERALS_STRATEGY` in `core/plugins/data/search`
* Remove `ng-non-bindable` leftovers

Signed-off-by: Miki <miki@amazon.com>

---------

Signed-off-by: Miki <miki@amazon.com>

(cherry picked from commit 10ae4ee)
Signed-off-by: Miki <miki@amazon.com>
yujin-emma pushed a commit to yujin-emma/OpenSearch-Dashboards that referenced this pull request Feb 5, 2024
* Fix the usage of `pegjs` in tasks

Signed-off-by: Miki <miki@amazon.com>

* [Discover] Add long numerals support

* Add long numerals support to Discover tabular view, document view, inspector, hash-url, and share
* Use a fork of `numeral-js` that supports long numerals
* Patch `rison` to correctly serialize BigInts
* Replace the uses of `withLongNumerals` with `withLongNumeralsSupport` to match the rest of the codebase and mark `withLongNumerals` for deprecation
* Add `withLongNumeralsSupport` as an option to `code/public/http/fetch`
* Add long numerals support to `UiSettingsClient`
* Add long numerals support to `core/server/http/router` response handler
* Add long numerals support to `RangeFilter` and `FilterBar`
* Add long numerals support to `kuery/ast`
* Introduce `OPENSEARCH_SEARCH_WITH_LONG_NUMERALS_STRATEGY` in `core/plugins/data/search`
* Remove `ng-non-bindable` leftovers

Signed-off-by: Miki <miki@amazon.com>

---------

Signed-off-by: Miki <miki@amazon.com>
Signed-off-by: yujin-emma <yujin.emma.work@gmail.com>
abbyhu2000 pushed a commit that referenced this pull request Feb 6, 2024
* Fix the usage of `pegjs` in tasks



* [Discover] Add long numerals support

* Add long numerals support to Discover tabular view, document view, inspector, hash-url, and share
* Use a fork of `numeral-js` that supports long numerals
* Patch `rison` to correctly serialize BigInts
* Replace the uses of `withLongNumerals` with `withLongNumeralsSupport` to match the rest of the codebase and mark `withLongNumerals` for deprecation
* Add `withLongNumeralsSupport` as an option to `code/public/http/fetch`
* Add long numerals support to `UiSettingsClient`
* Add long numerals support to `core/server/http/router` response handler
* Add long numerals support to `RangeFilter` and `FilterBar`
* Add long numerals support to `kuery/ast`
* Introduce `OPENSEARCH_SEARCH_WITH_LONG_NUMERALS_STRATEGY` in `core/plugins/data/search`
* Remove `ng-non-bindable` leftovers



---------



(cherry picked from commit 10ae4ee)

Signed-off-by: Miki <miki@amazon.com>
Co-authored-by: Ashwin P Chandran <ashwinpc@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants