mirror of
https://github.com/redmine/redmine.git
synced 2025-11-15 17:56:03 +01:00
Optimize Project#notified_users to improve issue create/update speed (#23328).
Patch by Holger Just (@hjust). git-svn-id: https://svn.redmine.org/redmine/trunk@22590 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -34,6 +34,7 @@ class Project < ActiveRecord::Base
|
||||
# Memberships of active users only
|
||||
has_many :members,
|
||||
lambda {joins(:principal).where(:users => {:type => 'User', :status => Principal::STATUS_ACTIVE})}
|
||||
has_many :users, through: :members
|
||||
has_many :enabled_modules, :dependent => :delete_all
|
||||
has_and_belongs_to_many :trackers, lambda {order(:position)}
|
||||
has_many :issues, :dependent => :destroy
|
||||
@@ -625,13 +626,7 @@ class Project < ActiveRecord::Base
|
||||
|
||||
# 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}
|
||||
users.where('members.mail_notification = ? OR users.mail_notification = ?', true, 'all')
|
||||
end
|
||||
|
||||
# Returns a scope of all custom fields enabled for project issues
|
||||
|
||||
Reference in New Issue
Block a user