summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-03-02 16:27:14 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-03-02 16:27:14 +0000
commit9c4014f446d884e88305851204950b907e0f891c (patch)
tree8273aa886d1ffc07473fe5bfb0aa8e2b7f487748
parent1c0988cad384852011beecf6c29eae0d0133aa55 (diff)
downloadredmine-9c4014f446d884e88305851204950b907e0f891c.tar.gz
redmine-9c4014f446d884e88305851204950b907e0f891c.zip
Use a single query to retrieve issues on the roadmap.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9057 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/controllers/versions_controller.rb15
1 files changed, 7 insertions, 8 deletions
diff --git a/app/controllers/versions_controller.rb b/app/controllers/versions_controller.rb
index d7225344f..34a5e2e34 100644
--- a/app/controllers/versions_controller.rb
+++ b/app/controllers/versions_controller.rb
@@ -45,14 +45,13 @@ class VersionsController < ApplicationController
end
@issues_by_version = {}
- unless @selected_tracker_ids.empty?
- @versions.each do |version|
- issues = version.fixed_issues.visible.find(:all,
- :include => [:project, :status, :tracker, :priority],
- :conditions => {:tracker_id => @selected_tracker_ids, :project_id => project_ids},
- :order => "#{Project.table_name}.lft, #{Tracker.table_name}.position, #{Issue.table_name}.id")
- @issues_by_version[version] = issues
- end
+ if @selected_tracker_ids.any? && @versions.any?
+ issues = Issue.visible.all(
+ :include => [:project, :status, :tracker, :priority, :fixed_version],
+ :conditions => {:tracker_id => @selected_tracker_ids, :project_id => project_ids, :fixed_version_id => @versions.map(&:id)},
+ :order => "#{Project.table_name}.lft, #{Tracker.table_name}.position, #{Issue.table_name}.id"
+ )
+ @issues_by_version = issues.group_by(&:fixed_version)
end
@versions.reject! {|version| !project_ids.include?(version.project_id) && @issues_by_version[version].blank?}
}