diff options
author | Go MAEDA <maeda@farend.jp> | 2023-01-21 08:50:12 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2023-01-21 08:50:12 +0000 |
commit | 055856825783b7e1303c7cad8e99779d5f4567fc (patch) | |
tree | 27597beb03c848a9f07ef9ada943d62ded708e22 /app/models | |
parent | 9d65eee4248acef921d102f1e614618514afcd51 (diff) | |
download | redmine-055856825783b7e1303c7cad8e99779d5f4567fc.tar.gz redmine-055856825783b7e1303c7cad8e99779d5f4567fc.zip |
Improve index usability for Project#project_condition (#38198).
Patch by Holger Just.
git-svn-id: https://svn.redmine.org/redmine/trunk@22069 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/project.rb | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index 80bea61d9..43a55428e 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -329,15 +329,17 @@ class Project < ActiveRecord::Base # Returns a :conditions SQL string that can be used to find the issues associated with this project. # # Examples: - # project.project_condition(true) => "(projects.id = 1 OR (projects.lft > 1 AND projects.rgt < 10))" + # project.project_condition(true) => "(projects.lft >= 1 AND projects.rgt <= 10)" # project.project_condition(false) => "projects.id = 1" def project_condition(with_subprojects) - cond = "#{Project.table_name}.id = #{id}" if with_subprojects - cond = "(#{cond} OR (#{Project.table_name}.lft > #{lft} AND " \ - "#{Project.table_name}.rgt < #{rgt}))" + "(" \ + "#{Project.table_name}.lft >= #{lft} AND " \ + "#{Project.table_name}.rgt <= #{rgt}" \ + ")" + else + "#{Project.table_name}.id = #{id}" end - cond end def self.find(*args) |