summaryrefslogtreecommitdiff
path: root/app/models/audit_event.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-27 00:08:09 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-27 00:08:09 +0000
commit6348b76e4b4dd4e398915c3150c1d02aafa3f13b (patch)
treec8c53d4adac92d4576d73d33ebeeaa62a2626b12 /app/models/audit_event.rb
parent03a70b84edfb86bc27f9234e1f1d157d3a33c555 (diff)
downloadgitlab-ce-6348b76e4b4dd4e398915c3150c1d02aafa3f13b.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/audit_event.rb')
-rw-r--r--app/models/audit_event.rb16
1 files changed, 15 insertions, 1 deletions
diff --git a/app/models/audit_event.rb b/app/models/audit_event.rb
index 03841917bbf..7ff0076c3e3 100644
--- a/app/models/audit_event.rb
+++ b/app/models/audit_event.rb
@@ -30,12 +30,26 @@ class AuditEvent < ApplicationRecord
end
def author_name
- self.user.name
+ lazy_author.name
end
def formatted_details
details.merge(details.slice(:from, :to).transform_values(&:to_s))
end
+
+ def lazy_author
+ BatchLoader.for(author_id).batch(default_value: default_author_value) do |author_ids, loader|
+ User.where(id: author_ids).find_each do |user|
+ loader.call(user.id, user)
+ end
+ end
+ end
+
+ private
+
+ def default_author_value
+ ::Gitlab::Audit::NullAuthor.for(author_id, details[:author_name])
+ end
end
AuditEvent.prepend_if_ee('EE::AuditEvent')