mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-09 00:49:07 +08:00
Fix filtering archived global search results [SCI-10696]
This commit is contained in:
parent
a5d6f7d316
commit
a7cb519faa
3 changed files with 14 additions and 3 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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 || []
|
||||
|
||||
|
|
Loading…
Reference in a new issue