-
Notifications
You must be signed in to change notification settings - Fork 109
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 for improving user search. #3407
base: development
Are you sure you want to change the base?
Conversation
7467839
to
6808847
Compare
Will rebase with development once @benjaminfaure has released v4.2. That should fix test failures. |
6808847
to
ec8f36b
Compare
Currently Searches of users using search "firstname_<empty_spaces>_surname" will only get valid matches if the _<empty_spaces>_ is a single empty space. Change: The search term string is squished to remove extra empty spaces. As a result search terms like "Jill Bloggs" (one space between) and "Jill Bloggs" (more than one space between) will both return the same results.
ec8f36b
to
4e6995e
Compare
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.
Yes, if you see it elsewhere then it should also be patched. I am not going to have time to do that in the next day or so, so feel free to update in this branch if you want. :) |
Cool. @johnpinto1 would you want me to do that? Or would you prefer to take care of it yourself? |
Please do @aaronskiba. Cheers! |
I was working on this and discovered a bit of an edge-case that complicates this PR a bit: The issue is when the string being searched (User.firstname + User.surname, Org.name, etc.) actually has double spaces built-in. SELECT firstname, surname
FROM users
WHERE firstname LIKE '% '
OR surname LIKE ' %'; When I execute the above query on a recent DMP Assistant DB dump from production, I get 307 returned results. As a single example, there is a User with first name "Susan " and last name "Brown". Searches for both However, when I revert the changes from this PR, the User is returned when I search I like the idea behind this PR, but to avoid this edge-case, I'm thinking that in addition to the search string, we'll have to apply the same |
@aaronskiba Well spotted, sounds good to me. |
Currently Searches of users using search "firstname_<empty_spaces>_surname" will only get valid matches if the <empty_spaces> is a single empty space.
Change:
The search term string is squished to remove extra empty spaces. As a
result search terms like "Jill Bloggs" (one space between) and "Jill Bloggs" (more than one space between) will both return the same results.
Reference:
https://api.rubyonrails.org/classes/String.html#method-i-squish