Fix filtering archived global search results [SCI-10696]

This commit is contained in:
Andrej 2024-05-13 11:29:31 +02:00
parent a5d6f7d316
commit a7cb519faa
3 changed files with 14 additions and 3 deletions

View file

@ -73,7 +73,7 @@ class Experiment < ApplicationRecord
.where(user_assignments: { team: teams })
.where_attributes_like_boolean(SEARCHABLE_ATTRIBUTES, query, options)
new_query = new_query.active unless include_archived
new_query = new_query.joins(:project).active.where(projects: { archived: false }) unless include_archived
new_query
end

View file

@ -119,7 +119,11 @@ class MyModule < ApplicationRecord
.where(user_assignments: { team: teams })
.where_attributes_like_boolean(SEARCHABLE_ATTRIBUTES, query, options)
new_query = new_query.active unless include_archived
unless include_archived
new_query = new_query.joins(experiment: :project)
.active
.where(experiments: { archived: false }, projects: { archived: false })
end
new_query
end

View file

@ -184,7 +184,14 @@ class Protocol < ApplicationRecord
"AND my_module_user_assignments.assignable_id = my_modules.id")
.where(my_module_user_assignments: { user_id: user })
.where(team: teams)
protocols = protocols.active unless include_archived
unless include_archived
protocols = protocols.joins(my_module: { experiment: :project })
.active
.where(my_modules: { archived: false },
experiments: { archived: false },
projects: { archived: false })
end
protocols.select(:id)
end || []