From c6fe90006eea5961c7a1acaf06964f0f390d0878 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 6 May 2015 12:55:33 +1000 Subject: [PATCH] correcly grap name, omit needless query --- app/mailers/user_notifications.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/mailers/user_notifications.rb b/app/mailers/user_notifications.rb index ef6e8ae07bf..af2e01ad999 100644 --- a/app/mailers/user_notifications.rb +++ b/app/mailers/user_notifications.rb @@ -188,7 +188,8 @@ class UserNotifications < ActionMailer::Base user_name = @notification.data_hash[:original_username] if @post && SiteSetting.enable_names && SiteSetting.display_name_on_posts - user_name = User.find_by(id: @post.user_id).name if !User.find_by(id: @post.user_id).name.empty? + name = User.where(id: @post.user_id).pluck(:name).first + user_name = name unless name.blank? end notification_type = opts[:notification_type] || Notification.types[@notification.notification_type].to_s