Merge pull request #7910 from aignatov-bio/ai-sci-11129-improve-storage-locations-search

Improve storage locations search [SCI-11129]
This commit is contained in:
aignatov-bio 2024-10-02 12:39:36 +02:00 committed by GitHub
commit f6bb7022d9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 20 additions and 2 deletions

View file

@ -6,6 +6,7 @@ class StorageLocation < ApplicationRecord
ID_PREFIX = 'SL' ID_PREFIX = 'SL'
include PrefixedIdModel include PrefixedIdModel
include Shareable include Shareable
include SearchableModel
default_scope -> { kept } default_scope -> { kept }

View file

@ -44,8 +44,25 @@ module Lists
@records = @records.where(parent_id: @parent_id) @records = @records.where(parent_id: @parent_id)
end end
@records = @records.where('LOWER(storage_locations.name) ILIKE ?', "%#{@filters[:query].downcase}%") if @filters[:query].present? if @filters[:query].present?
@records = @records.where('LOWER(storage_locations.name) ILIKE ?', "%#{@params[:search].downcase}%") if @params[:search].present? @records = @records.where_attributes_like(
[
'storage_locations.name',
'storage_locations.description',
StorageLocation::PREFIXED_ID_SQL
], @filters[:query]
)
end
if @params[:search].present?
@records = @records.where_attributes_like(
[
'storage_locations.name',
'storage_locations.description',
StorageLocation::PREFIXED_ID_SQL
], @params[:search]
)
end
end end
private private