From da6632c686ec70f9b2ee278c689b9ea7f3172acd Mon Sep 17 00:00:00 2001 From: Andrej Date: Mon, 20 May 2024 13:20:13 +0200 Subject: [PATCH] Add global search filtering ability by assigned users [SCI-10723] --- app/controllers/search_controller.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index be39a4b35..f7175c2d9 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -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