-
Notifications
You must be signed in to change notification settings - Fork 44
fix error when filter value not found in items set #130
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
Conversation
Thank you for your first contribution! In my opinion we should be returning zero results instead of ignoring not existing filters like in your case "thriller". The reason is - it directly informs the user that their criteria didn't match anything, prompting them to reconsider their filter choices and users won't be under the impression that they successfully applied all filters when in reality some were invalid. Would it work with your use case ? |
Actually, this is correct when WDYT ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've finished reviewing your PR. Once you've addressed the feedback, please let me know so I can take a final look.
tests/searchSpec.js
Outdated
|
||
it('makes search with non existing filter value with conjunction false should return results', function test(done) { | ||
|
||
configuration.aggregations.category.conjunction = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test modifies a shared configuration value (configuration.aggregations.category.conjunction
). For test independence, please consider:
- Using a dedicated configuration copy just for this test, or
- Resetting the configuration to its initial state post-test.
This approach ensures tests don't inadvertently influence each other.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds good.
I added a localConfiguration
from a Lodash clone so it's clearer those 2 tests are set on a different config. Let me know if it works for you.
Looks great to me! Merging now. |
Released new version https://github.com/itemsapi/itemsjs/releases/tag/v2.1.22 |
awesome, thanks for your help 🙏 |
It’s my first time contributing to a public repo so let me know if anything needs to be corrected. I added a test to explain the specific usecase covered.
This pr is adding the possibility of having a non existing value in the filters. We want to have a predefined set of filters, but also having the possibility that the filtered data (items) will sometimes not include one of the options.
example: possible filters for categories would be
comedy
,drama
orthriller
by default, but the related items would only containscomedy
ordrama
categories. Added a fallback to an emptyFastBitset
when needed, so it would not break.Let me know if any changes are necessary and thanks for the lib!