From 74678391f03996f717481b8c39a7e67e5fb238ab Mon Sep 17 00:00:00 2001 From: John Pinto Date: Wed, 10 Apr 2024 11:28:40 +0100 Subject: [PATCH] Fix for improving user search. Currently Searches of users using search "firstname__surname" will only get valid matches if the __ 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. --- app/models/user.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index c3ff357961..e8afb3f93e 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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