mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-20 15:31:12 +00:00
Makes Project#assignable_users return a scope that prevents 2*n queries.
git-svn-id: http://svn.redmine.org/redmine/trunk@13509 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
c0f082ad02
commit
2d64a22dd9
@ -734,7 +734,7 @@ class Issue < ActiveRecord::Base
|
||||
|
||||
# Users the issue can be assigned to
|
||||
def assignable_users
|
||||
users = project.assignable_users
|
||||
users = project.assignable_users.to_a
|
||||
users << author if author
|
||||
users << assigned_to if assigned_to
|
||||
users.uniq.sort
|
||||
|
||||
@ -504,15 +504,17 @@ class Project < ActiveRecord::Base
|
||||
Member.delete_all(['project_id = ?', id])
|
||||
end
|
||||
|
||||
# Users/groups issues can be assigned to
|
||||
# Return a Principal scope of users/groups issues can be assigned to
|
||||
def assignable_users
|
||||
types = ['User']
|
||||
types << 'Group' if Setting.issue_group_assignment?
|
||||
|
||||
member_principals.
|
||||
select {|m| types.include?(m.principal.type) && m.roles.detect(&:assignable?)}.
|
||||
map(&:principal).
|
||||
sort
|
||||
@assignable_users ||= Principal.
|
||||
active.
|
||||
joins(:members => :roles).
|
||||
where(:type => types, :members => {:project_id => id}, :roles => {:assignable => true}).
|
||||
uniq.
|
||||
sorted
|
||||
end
|
||||
|
||||
# Returns the mail addresses of users that should be always notified on project events
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user