diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2013-02-17 12:41:31 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2013-02-17 12:41:31 +0000 |
commit | 64bbf64fb6f3b9e89f3180df28c5f06f54638eb8 (patch) | |
tree | 8b4f0f2640a9f0c101c38dcf1c79f0fa40b6b508 /app/models | |
parent | d8e4a8fb320625474e20901b4070763bd697807a (diff) | |
download | redmine-64bbf64fb6f3b9e89f3180df28c5f06f54638eb8.tar.gz redmine-64bbf64fb6f3b9e89f3180df28c5f06f54638eb8.zip |
Optimizes the SQL query behind Principal#member_of.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11426 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/principal.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/app/models/principal.rb b/app/models/principal.rb index 97babba1c..b6f41d535 100644 --- a/app/models/principal.rb +++ b/app/models/principal.rb @@ -57,7 +57,7 @@ class Principal < ActiveRecord::Base where("1=0") else ids = projects.map(&:id) - active.where("#{Principal.table_name}.id IN (SELECT DISTINCT user_id FROM #{Member.table_name} WHERE project_id IN (?))", ids) + active.uniq.joins(:members).where("#{Member.table_name}.project_id IN (?)", ids) end } # Principals that are not members of projects |