diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-27 00:08:09 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-27 00:08:09 +0000 |
commit | 6348b76e4b4dd4e398915c3150c1d02aafa3f13b (patch) | |
tree | c8c53d4adac92d4576d73d33ebeeaa62a2626b12 /app/models/audit_event.rb | |
parent | 03a70b84edfb86bc27f9234e1f1d157d3a33c555 (diff) | |
download | gitlab-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.rb | 16 |
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') |