-
Notifications
You must be signed in to change notification settings - Fork 88
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
Convert bool filters to 0 or 1 when querying the search service #3202
base: master
Are you sure you want to change the base?
Conversation
# This is needed or the test will fail if you have a search service configured in your udata.cfg file. | ||
current_app.config["SEARCH_SERVICE_API_URL"] = "" | ||
|
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 is unrelated to this PR, but this test will fail if you have a search service configured, which I needed to fix this PR ;)
# This is needed or the test will fail if you have a search service configured in your udata.cfg file. | ||
current_app.config["SEARCH_SERVICE_API_URL"] = "" |
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 is unrelated to this PR, but this test will fail if you have a search service configured, which I needed to fix this PR ;)
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.
Thank you for this PR!
I think the multiplication of endpoints and API shows all the small consistencies issues sadly
# HACK: use the `.__class__.__name__` to avoid having to import `BoolFilter` here, as importing it at the top would make a import loop. | ||
if self.adapter.filters[name].__class__.__name__ == "BoolFilter": | ||
# The search service uses 1 and 0 for booleans. | ||
param_value = 1 if value == "true" else 0 |
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.
Somehow on udata-search-service side, featured is not set to 0 or 1 but 1 or 4 (probably for poorly decided scoring reasons) 🥲
# HACK: use the `.__class__.__name__` to avoid having to import `BoolFilter` here, as importing it at the top would make a import loop. | ||
if self.adapter.filters[name].__class__.__name__ == "BoolFilter": | ||
# The search service uses 1 and 0 for booleans. | ||
param_value = 1 if value == "true" else 0 |
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 think if value is True
and not true
when it comes from the udata-front search view: /fr/datasets/
Fixes #1456