summaryrefslogtreecommitdiffstats
path: root/app/models/project.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2016-01-16 08:22:06 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2016-01-16 08:22:06 +0000
commit3a52b08405ade9941e93e4fa914d8a105b9194b4 (patch)
tree8f4bd46d7dba3df078aa5d5294d4dbd699035727 /app/models/project.rb
parentdaff49d5e5bfdb407567870d287bcfec875da791 (diff)
downloadredmine-3a52b08405ade9941e93e4fa914d8a105b9194b4.tar.gz
redmine-3a52b08405ade9941e93e4fa914d8a105b9194b4.zip
Use association instead of a manual JOIN (#21583).
Patch by Ondřej. git-svn-id: http://svn.redmine.org/redmine/trunk@15062 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/project.rb')
-rw-r--r--app/models/project.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index 9868e0444..c9d47b21b 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -425,9 +425,9 @@ class Project < ActiveRecord::Base
def rolled_up_trackers
@rolled_up_trackers ||=
Tracker.
- joins(:projects).
- joins("JOIN #{EnabledModule.table_name} ON #{EnabledModule.table_name}.project_id = #{Project.table_name}.id AND #{EnabledModule.table_name}.name = 'issue_tracking'").
+ joins(projects: :enabled_modules).
where("#{Project.table_name}.lft >= ? AND #{Project.table_name}.rgt <= ? AND #{Project.table_name}.status <> ?", lft, rgt, STATUS_ARCHIVED).
+ where("#{EnabledModule.table_name}.name = ?", 'issue_tracking').
uniq.
sorted.
to_a