##// END OF EJS Templates
Makes Project#assignable_users return a scope that prevents 2*n queries....
Jean-Philippe Lang -
r13127:2d64a22dd928
parent child
Show More
@@ -734,7 +734,7 class Issue < ActiveRecord::Base
734
734
735 # Users the issue can be assigned to
735 # Users the issue can be assigned to
736 def assignable_users
736 def assignable_users
737 users = project.assignable_users
737 users = project.assignable_users.to_a
738 users << author if author
738 users << author if author
739 users << assigned_to if assigned_to
739 users << assigned_to if assigned_to
740 users.uniq.sort
740 users.uniq.sort
@@ -504,15 +504,17 class Project < ActiveRecord::Base
504 Member.delete_all(['project_id = ?', id])
504 Member.delete_all(['project_id = ?', id])
505 end
505 end
506
506
507 # Users/groups issues can be assigned to
507 # Return a Principal scope of users/groups issues can be assigned to
508 def assignable_users
508 def assignable_users
509 types = ['User']
509 types = ['User']
510 types << 'Group' if Setting.issue_group_assignment?
510 types << 'Group' if Setting.issue_group_assignment?
511
511
512 member_principals.
512 @assignable_users ||= Principal.
513 select {|m| types.include?(m.principal.type) && m.roles.detect(&:assignable?)}.
513 active.
514 map(&:principal).
514 joins(:members => :roles).
515 sort
515 where(:type => types, :members => {:project_id => id}, :roles => {:assignable => true}).
516 uniq.
517 sorted
516 end
518 end
517
519
518 # Returns the mail addresses of users that should be always notified on project events
520 # Returns the mail addresses of users that should be always notified on project events
General Comments 0
You need to be logged in to leave comments. Login now