summaryrefslogtreecommitdiffstats
path: root/app/models/project.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2016-06-18 06:42:25 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2016-06-18 06:42:25 +0000
commit6cd84af522bbc1904d937440a6ad2628cd75fce9 (patch)
tree21a89eae842660308c7d213cf22617633ac23ab8 /app/models/project.rb
parentbbd24fe350a3bdba18eaa3d1a1d9329fd538260d (diff)
downloadredmine-6cd84af522bbc1904d937440a6ad2628cd75fce9.tar.gz
redmine-6cd84af522bbc1904d937440a6ad2628cd75fce9.zip
Limits the tracker list in filters and issue counts (#285).
git-svn-id: http://svn.redmine.org/redmine/trunk@15540 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/project.rb')
-rw-r--r--app/models/project.rb28
1 files changed, 18 insertions, 10 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index e9b2647d4..b6bc13dde 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -421,16 +421,24 @@ class Project < ActiveRecord::Base
save
end
- # Returns an array of the trackers used by the project and its active sub projects
- def rolled_up_trackers
- @rolled_up_trackers ||=
- Tracker.
- 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
+ # Returns a scope of the trackers used by the project and its active sub projects
+ def rolled_up_trackers(include_subprojects=true)
+ if include_subprojects
+ @rolled_up_trackers ||= rolled_up_trackers_base_scope.
+ where("#{Project.table_name}.lft >= ? AND #{Project.table_name}.rgt <= ?", lft, rgt)
+ else
+ rolled_up_trackers_base_scope.
+ where(:projects => {:id => id})
+ end
+ end
+
+ def rolled_up_trackers_base_scope
+ Tracker.
+ joins(projects: :enabled_modules).
+ where("#{Project.table_name}.status <> ?", STATUS_ARCHIVED).
+ where(:enabled_modules => {:name => 'issue_tracking'}).
+ uniq.
+ sorted
end
# Closes open and locked project versions that are completed