From 4cae62d8e869718b537fccc667802550194139f3 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 30 Jan 2016 15:37:27 +0000 Subject: Query project_statement - do not collect ids of subtree (#21611). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Patch by Ondřej Ezr. git-svn-id: http://svn.redmine.org/redmine/trunk@15135 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/query.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'app/models') diff --git a/app/models/query.rb b/app/models/query.rb index ddc59f99b..55ae0dc9a 100644 --- a/app/models/query.rb +++ b/app/models/query.rb @@ -567,22 +567,24 @@ class Query < ActiveRecord::Base def project_statement project_clauses = [] if project && !project.descendants.active.empty? - ids = [project.id] if has_filter?("subproject_id") case operator_for("subproject_id") when '=' # include the selected subprojects - ids += values_for("subproject_id").each(&:to_i) + ids = [project.id] + values_for("subproject_id").each(&:to_i) + project_clauses << "#{Project.table_name}.id IN (%s)" % ids.join(',') when '!*' # main project only + project_clauses << "#{Project.table_name}.id = %d" % project.id else # all subprojects - ids += project.descendants.collect(&:id) + project_clauses << "#{Project.table_name}.lft >= #{project.lft} AND #{Project.table_name}.rgt <= #{project.rgt}" end elsif Setting.display_subprojects_issues? - ids += project.descendants.collect(&:id) + project_clauses << "#{Project.table_name}.lft >= #{project.lft} AND #{Project.table_name}.rgt <= #{project.rgt}" + else + project_clauses << "#{Project.table_name}.id = %d" % project.id end - project_clauses << "#{Project.table_name}.id IN (%s)" % ids.join(',') elsif project project_clauses << "#{Project.table_name}.id = %d" % project.id end -- cgit v1.2.3