Commit 5f779809 authored by jplang's avatar jplang

Query project_statement - do not collect ids of subtree (#21611).

Patch by Ondřej Ezr.

git-svn-id: https://svn.redmine.org/redmine/trunk@15135 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent f6590b00
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment