summaryrefslogtreecommitdiffstats
path: root/app/models/query.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2016-01-30 15:37:27 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2016-01-30 15:37:27 +0000
commit4cae62d8e869718b537fccc667802550194139f3 (patch)
treefeec7abd5d3664adbc3ddee146ca163eaa054e8a /app/models/query.rb
parent71ec68cb731d03a878b228b57f8d2c61019ab9eb (diff)
downloadredmine-4cae62d8e869718b537fccc667802550194139f3.tar.gz
redmine-4cae62d8e869718b537fccc667802550194139f3.zip
Query project_statement - do not collect ids of subtree (#21611).
Patch by Ondřej Ezr. git-svn-id: http://svn.redmine.org/redmine/trunk@15135 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/query.rb')
-rw-r--r--app/models/query.rb12
1 files changed, 7 insertions, 5 deletions
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