Actions
Patch #37135
closedReduce extra queries in ProjectQuery.default
Start date:
Due date:
% Done:
0%
Estimated time:
Description
Same as #36503 but for ProjectQuery.
Currently redmine tries to select default_project_query
even if settings are empty.
diff --git a/app/models/project_query.rb b/app/models/project_query.rb index 002437aeb..8c6643c7b 100644 --- a/app/models/project_query.rb +++ b/app/models/project_query.rb @@ -39,10 +39,13 @@ class ProjectQuery < Query def self.default(project: nil, user: User.current) query = nil - if user&.logged? - query = find_by_id user.pref.default_project_query + if user&.logged? && (query_id = user.pref.default_project_query).present? + query = find_by(id: query_id) end - query || find_by_id(Setting.default_project_query) + if query.nil? && (query_id = Setting.default_project_query).present? + query = find_by(id: query_id) + end + query end def initialize(attributes=nil, *args)
Related issues
Actions