From c19176a5c48e33e6bcfe280736092154deb58181 Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Tue, 4 Jun 2024 09:37:34 +0000 Subject: [PATCH] Reduce an extra SQL query in IssuesController#retrieve_default_query (#40775). Patch by Go MAEDA (@maeda). git-svn-id: https://svn.redmine.org/redmine/trunk@22854 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/issues_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 76e7ed921..8528a2fca 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -502,8 +502,9 @@ class IssuesController < ApplicationController return end if !params[:set_filter] && use_session && session[:issue_query] + # Don't apply the default query if a valid query id is set in the session query_id, project_id = session[:issue_query].values_at(:id, :project_id) - return if IssueQuery.where(id: query_id).exists? && project_id == @project&.id + return if query_id && project_id == @project&.id && IssueQuery.exists?(id: query_id) end if default_query = IssueQuery.default(project: @project) params[:query_id] = default_query.id -- 2.39.5