##// 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 735 # Users the issue can be assigned to
736 736 def assignable_users
737 users = project.assignable_users
737 users = project.assignable_users.to_a
738 738 users << author if author
739 739 users << assigned_to if assigned_to
740 740 users.uniq.sort
@@ -504,15 +504,17 class Project < ActiveRecord::Base
504 504 Member.delete_all(['project_id = ?', id])
505 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 508 def assignable_users
509 509 types = ['User']
510 510 types << 'Group' if Setting.issue_group_assignment?
511 511
512 member_principals.
513 select {|m| types.include?(m.principal.type) && m.roles.detect(&:assignable?)}.
514 map(&:principal).
515 sort
512 @assignable_users ||= Principal.
513 active.
514 joins(:members => :roles).
515 where(:type => types, :members => {:project_id => id}, :roles => {:assignable => true}).
516 uniq.
517 sorted
516 518 end
517 519
518 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