Browse Source

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
tags/2.3.0
Jean-Philippe Lang 11 years ago
parent
commit
64bbf64fb6
1 changed files with 1 additions and 1 deletions
  1. 1
    1
      app/models/principal.rb

+ 1
- 1
app/models/principal.rb View File

@@ -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

Loading…
Cancel
Save