mirror of
https://github.com/redmine/redmine.git
synced 2026-01-15 03:52:51 +01:00
Optimize watchers list rendering by eager loading email addresses (#42589).
Patch by Go MAEDA (user:maeda). git-svn-id: https://svn.redmine.org/redmine/trunk@23722 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -48,7 +48,9 @@ module WatchersHelper
|
||||
def watchers_list(object)
|
||||
remove_allowed = User.current.allowed_to?(:"delete_#{object.class.name.underscore}_watchers", object.project)
|
||||
content = ''.html_safe
|
||||
lis = object.watcher_users.sorted.collect do |user|
|
||||
scope = object.watcher_users
|
||||
scope = scope.includes(:email_address) if Setting.gravatar_enabled?
|
||||
lis = scope.sorted.collect do |user|
|
||||
s = ''.html_safe
|
||||
s << avatar(user, :size => "16").to_s if user.is_a?(User)
|
||||
s << link_to_principal(user, class: user.class.to_s.downcase)
|
||||
|
||||
@@ -35,6 +35,8 @@ class Principal < ApplicationRecord
|
||||
:foreign_key => 'user_id'
|
||||
has_many :projects, :through => :memberships
|
||||
has_many :issue_categories, :foreign_key => 'assigned_to_id', :dependent => :nullify
|
||||
# Always returns nil for groups
|
||||
has_one :email_address, lambda {where :is_default => true}, :autosave => true, :foreign_key => 'user_id'
|
||||
|
||||
validate :validate_status
|
||||
|
||||
|
||||
@@ -91,7 +91,6 @@ class User < Principal
|
||||
has_one :preference, :dependent => :destroy, :class_name => 'UserPreference'
|
||||
has_one :atom_token, lambda {where "#{table.name}.action='feeds'"}, :class_name => 'Token'
|
||||
has_one :api_token, lambda {where "#{table.name}.action='api'"}, :class_name => 'Token'
|
||||
has_one :email_address, lambda {where :is_default => true}, :autosave => true
|
||||
has_many :email_addresses, :dependent => :delete_all
|
||||
belongs_to :auth_source
|
||||
|
||||
|
||||
Reference in New Issue
Block a user