Project

General

Profile

Patch #23328 » optimize-project-notified-users.patch

Go MAEDA, 2024-01-02 10:48

View differences:

app/models/project.rb
# Returns the users that should be notified on project events
def notified_users
# TODO: User part should be extracted to User#notify_about?
users =
members.preload(:principal).select do |m|
m.principal.present? &&
(m.mail_notification? || m.principal.mail_notification == 'all')
end
users.collect {|m| m.principal}
subquery =
members.select(:user_id)
.where.associated(:principal)
.where('members.mail_notification = ? OR users.mail_notification = ?', true, 'all')
User.where(id: subquery)
end
# Returns a scope of all custom fields enabled for project issues
(3-3/7)