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
This commit is contained in:
Jean-Philippe Lang 2012-03-02 16:27:14 +00:00
parent 1c0988cad3
commit 9c4014f446
1 changed files with 7 additions and 8 deletions

View File

@ -45,14 +45,13 @@ class VersionsController < ApplicationController
end end
@issues_by_version = {} @issues_by_version = {}
unless @selected_tracker_ids.empty? if @selected_tracker_ids.any? && @versions.any?
@versions.each do |version| issues = Issue.visible.all(
issues = version.fixed_issues.visible.find(:all, :include => [:project, :status, :tracker, :priority, :fixed_version],
:include => [:project, :status, :tracker, :priority], :conditions => {:tracker_id => @selected_tracker_ids, :project_id => project_ids, :fixed_version_id => @versions.map(&:id)},
:conditions => {:tracker_id => @selected_tracker_ids, :project_id => project_ids}, :order => "#{Project.table_name}.lft, #{Tracker.table_name}.position, #{Issue.table_name}.id"
:order => "#{Project.table_name}.lft, #{Tracker.table_name}.position, #{Issue.table_name}.id") )
@issues_by_version[version] = issues @issues_by_version = issues.group_by(&:fixed_version)
end
end end
@versions.reject! {|version| !project_ids.include?(version.project_id) && @issues_by_version[version].blank?} @versions.reject! {|version| !project_ids.include?(version.project_id) && @issues_by_version[version].blank?}
} }