Merge pull request #7572 from rekonder/aj_SCI_10723

Add global search filtering ability by assigned users [SCI-10723]
This commit is contained in:
ajugo 2024-05-20 13:42:48 +02:00 committed by GitHub
commit d49bf05299
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -247,6 +247,12 @@ class SearchController < ApplicationController
def filter_users!(model)
@records = @records.joins("INNER JOIN activities ON #{model.model_name.collection}.id = activities.subject_id
AND activities.subject_type= '#{model.name}'")
.where('activities.owner_id': @filters[:users]&.values)
user_ids = @filters[:users]&.values
@records = if model.name == 'MyModule'
@records.where('activities.owner_id IN (?) OR users.id IN (?)', user_ids, user_ids)
else
@records.where('activities.owner_id': user_ids)
end
end
end