-
Notifications
You must be signed in to change notification settings - Fork 222
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
fix(ts): correct search response for facets_stats #1229
Conversation
Huh weirdly only key not in camelCase |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
Basically we had two methods to turn a number (or string) into a precision: 1. Math.floor(min * pow) / pow 2. Number(Number(v).toFixed(precision)) these behave different for precision 0 & a number over .5, let's say 1.5 turns into 1 for method 1, and into 2 for method 2. This is a bug (not caught by most of our tests, notably the ones i had to change) and causes the range to change to a number it's not supposed to be. Pay special attention to the new `toPrecision` utility, and the places it was used. At the same time I also converted to TypeScript, but not the components themselves, since that was too much work. typescript for tests is expected to fail until algolia/algoliasearch-client-javascript#1229 is released (since now certain parts aren't random objects, but rather search responses) The version for the helper is bumped for better typescript support as well.
Basically we had two methods to turn a number (or string) into a precision: 1. Math.floor(min * pow) / pow 2. Number(Number(v).toFixed(precision)) these behave different for precision 0 & a number over .5, let's say 1.5 turns into 1 for method 1, and into 2 for method 2. This is a bug (not caught by most of our tests, notably the ones i had to change) and causes the range to change to a number it's not supposed to be. Pay special attention to the new `toPrecision` utility, and the places it was used. At the same time I also converted to TypeScript, but not the components themselves, since that was too much work. typescript for tests is expected to fail until algolia/algoliasearch-client-javascript#1229 is released (since now certain parts aren't random objects, but rather search responses) The version for the helper is bumped for better typescript support as well. update types requires algolia/algoliasearch-client-javascript#1234 update client for fix in typing for tests update assertions in changed tests clarify why behaviour is like it is
* fix(range): consistently convert min & max to numbers Basically we had two methods to turn a number (or string) into a precision: 1. Math.floor(min * pow) / pow 2. Number(Number(v).toFixed(precision)) these behave different for precision 0 & a number over .5, let's say 1.5 turns into 1 for method 1, and into 2 for method 2. This is a bug (not caught by most of our tests, notably the ones i had to change) and causes the range to change to a number it's not supposed to be. Pay special attention to the new `toPrecision` utility, and the places it was used. At the same time I also converted to TypeScript, but not the components themselves, since that was too much work. typescript for tests is expected to fail until algolia/algoliasearch-client-javascript#1229 is released (since now certain parts aren't random objects, but rather search responses) The version for the helper is bumped for better typescript support as well. update types requires algolia/algoliasearch-client-javascript#1234 update client for fix in typing for tests update assertions in changed tests clarify why behaviour is like it is * address feedback * integrate fix from the helper avoiding workaround here
Just want say, thanks for fixing this. This has led me to at-least five |
Thanks @nojvek, if there's other places where you're currently suppressing errors, feel free to open pull requests / issues for that! |
https://www.algolia.com/doc/api-reference/api-methods/search/#method-response-facets_stats
as far as I can tell this was always wrong in v4