Patch #23328 » optimize-project-notified-users.patch
app/models/project.rb | ||
---|---|---|
626 | 626 |
# Returns the users that should be notified on project events |
627 | 627 |
def notified_users |
628 | 628 |
# TODO: User part should be extracted to User#notify_about? |
629 |
users = |
|
630 |
members.preload(:principal).select do |m| |
|
631 |
m.principal.present? && |
|
632 |
(m.mail_notification? || m.principal.mail_notification == 'all') |
|
633 |
end |
|
634 |
users.collect {|m| m.principal} |
|
629 |
subquery = |
|
630 |
members.select(:user_id) |
|
631 |
.where.associated(:principal) |
|
632 |
.where('members.mail_notification = ? OR users.mail_notification = ?', true, 'all') |
|
633 |
User.where(id: subquery) |
|
635 | 634 |
end |
636 | 635 | |
637 | 636 |
# Returns a scope of all custom fields enabled for project issues |