diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-04-02 10:18:05 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-04-02 10:18:05 +0000 |
commit | 80b59f3cf454364de42264f38c7e55da5fc9ebae (patch) | |
tree | 95eef72dfdfdf645aa573256fe85d5304b5fbd72 /app | |
parent | 859e8ae8283bf52bd6f221264e8cd5be7a1a4cfa (diff) | |
download | redmine-80b59f3cf454364de42264f38c7e55da5fc9ebae.tar.gz redmine-80b59f3cf454364de42264f38c7e55da5fc9ebae.zip |
Skip a few count(*) SQL queries on the issue list.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5292 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r-- | app/models/query.rb | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/app/models/query.rb b/app/models/query.rb index 6c4d1c7c1..87663aca8 100644 --- a/app/models/query.rb +++ b/app/models/query.rb @@ -216,14 +216,19 @@ class Query < ActiveRecord::Base if project # project specific filters - unless @project.issue_categories.empty? - @available_filters["category_id"] = { :type => :list_optional, :order => 6, :values => @project.issue_categories.collect{|s| [s.name, s.id.to_s] } } + categories = @project.issue_categories.all + unless categories.empty? + @available_filters["category_id"] = { :type => :list_optional, :order => 6, :values => categories.collect{|s| [s.name, s.id.to_s] } } end - unless @project.shared_versions.empty? - @available_filters["fixed_version_id"] = { :type => :list_optional, :order => 7, :values => @project.shared_versions.sort.collect{|s| ["#{s.project.name} - #{s.name}", s.id.to_s] } } + versions = @project.shared_versions.all + unless versions.empty? + @available_filters["fixed_version_id"] = { :type => :list_optional, :order => 7, :values => versions.sort.collect{|s| ["#{s.project.name} - #{s.name}", s.id.to_s] } } end - unless @project.descendants.active.empty? - @available_filters["subproject_id"] = { :type => :list_subprojects, :order => 13, :values => @project.descendants.visible.collect{|s| [s.name, s.id.to_s] } } + unless @project.leaf? + subprojects = @project.descendants.visible.all + unless subprojects.empty? + @available_filters["subproject_id"] = { :type => :list_subprojects, :order => 13, :values => subprojects.collect{|s| [s.name, s.id.to_s] } } + end end add_custom_fields_filters(@project.all_issue_custom_fields) else |