strip whitespace from search terms (#919)
This commit is contained in:
parent
bd4072f81c
commit
9df974a037
1 changed files with 4 additions and 4 deletions
|
@ -45,7 +45,7 @@ class SearchController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
search = '%' + term.downcase + '%'
|
search = '%' + term.downcase.strip + '%'
|
||||||
builder = policy_scope(Topic)
|
builder = policy_scope(Topic)
|
||||||
|
|
||||||
if filterByMetacode
|
if filterByMetacode
|
||||||
|
@ -93,7 +93,7 @@ class SearchController < ApplicationController
|
||||||
desc = true
|
desc = true
|
||||||
end
|
end
|
||||||
|
|
||||||
search = '%' + term.downcase + '%'
|
search = '%' + term.downcase.strip + '%'
|
||||||
builder = policy_scope(Map)
|
builder = policy_scope(Map)
|
||||||
|
|
||||||
builder = if desc
|
builder = if desc
|
||||||
|
@ -117,7 +117,7 @@ class SearchController < ApplicationController
|
||||||
|
|
||||||
# remove "mapper:" if appended at beginning
|
# remove "mapper:" if appended at beginning
|
||||||
term = term[7..-1] if term.downcase[0..6] == 'mapper:'
|
term = term[7..-1] if term.downcase[0..6] == 'mapper:'
|
||||||
search = term.downcase + '%'
|
search = term.downcase.strip + '%'
|
||||||
|
|
||||||
skip_policy_scope # TODO: builder = policy_scope(User)
|
skip_policy_scope # TODO: builder = policy_scope(User)
|
||||||
builder = User.where('LOWER("name") like ?', search)
|
builder = User.where('LOWER("name") like ?', search)
|
||||||
|
@ -136,7 +136,7 @@ class SearchController < ApplicationController
|
||||||
topic2id = params[:topic2id]
|
topic2id = params[:topic2id]
|
||||||
|
|
||||||
if term && !term.empty?
|
if term && !term.empty?
|
||||||
@synapses = policy_scope(Synapse).where('LOWER("desc") like ?', '%' + term.downcase + '%').order('"desc"')
|
@synapses = policy_scope(Synapse).where('LOWER("desc") like ?', '%' + term.downcase.strip + '%').order('"desc"')
|
||||||
|
|
||||||
@synapses = @synapses.uniq(&:desc)
|
@synapses = @synapses.uniq(&:desc)
|
||||||
elsif topic1id && !topic1id.empty?
|
elsif topic1id && !topic1id.empty?
|
||||||
|
|
Loading…
Reference in a new issue