Skip to content

Commit

Permalink
Fix for improving user search.
Browse files Browse the repository at this point in the history
Currently Searches of users using search "firstname_<empty_spaces>_surname"
will only get valid matches if the _<empty_spaces>_ is a single empty spaces.

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.
  • Loading branch information
John Pinto committed Apr 10, 2024
1 parent 0f805f6 commit 7467839
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class User < ApplicationRecord
if date_range?(term: term)
by_date_range(:created_at, term)
else
search_pattern = "%#{term}%"
search_pattern = "%#{term}%".squish!
# MySQL does not support standard string concatenation and since concat_ws
# or concat functions do not exist for sqlite, we have to come up with this
# conditional
Expand Down

0 comments on commit 7467839

Please sign in to comment.