##// END OF EJS Templates
Optimizes the SQL query behind Principal#member_of....
Jean-Philippe Lang -
r11196:64bbf64fb6f3
parent child
Show More
@@ -57,7 +57,7 class Principal < ActiveRecord::Base
57 57 where("1=0")
58 58 else
59 59 ids = projects.map(&:id)
60 active.where("#{Principal.table_name}.id IN (SELECT DISTINCT user_id FROM #{Member.table_name} WHERE project_id IN (?))", ids)
60 active.uniq.joins(:members).where("#{Member.table_name}.project_id IN (?)", ids)
61 61 end
62 62 }
63 63 # Principals that are not members of projects
General Comments 0
You need to be logged in to leave comments. Login now