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 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.
  • Loading branch information
John Pinto committed Apr 10, 2024
1 parent 0f805f6 commit ec8f36b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 4.2.1

### Changed
- A minor change to search that removes extra empty sppaces between words to allow user search to work if there are more than one space between firstname and surname, e,g., "Jill Blogss" and "Jill Bloggs" should return same results.

## v4.2.0

**Note this upgrade is mainly a migration from Bootstrap 3 to Bootstrap 5.**
Expand Down
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 ec8f36b

Please sign in to comment.