PERF: Remove N+1 query when saving a user.

This commit is contained in:
Guo Xiang Tan 2017-02-03 15:03:33 +08:00
parent 0988420b48
commit ec73224b5e
1 changed files with 1 additions and 1 deletions

View File

@ -941,7 +941,7 @@ class User < ActiveRecord::Base
domains = group.automatic_membership_email_domains.gsub('.', '\.') domains = group.automatic_membership_email_domains.gsub('.', '\.')
if user.reload.email =~ Regexp.new("@(#{domains})$", true) && !group.users.include?(user) if user.email =~ Regexp.new("@(#{domains})$", true) && !group.users.include?(user)
group.add(user) group.add(user)
GroupActionLogger.new(Discourse.system_user, group).log_add_user_to_group(user) GroupActionLogger.new(Discourse.system_user, group).log_add_user_to_group(user)
end end