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
This commit is contained in:
parent
d8e4a8fb32
commit
64bbf64fb6
|
@ -57,7 +57,7 @@ class Principal < ActiveRecord::Base
|
||||||
where("1=0")
|
where("1=0")
|
||||||
else
|
else
|
||||||
ids = projects.map(&:id)
|
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
|
end
|
||||||
}
|
}
|
||||||
# Principals that are not members of projects
|
# Principals that are not members of projects
|
||||||
|
|
Loading…
Reference in New Issue