diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-03 12:09:52 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-03 12:09:52 +0000 |
commit | 546ddc3f6ac96fdf09934390a938bb391d07dc94 (patch) | |
tree | d0c92fca27ee76b5a20b7bfb56bda6f057424127 /app/models/audit_event.rb | |
parent | 04baa85554ff13bdd4d6f4e6bb24119d17608fee (diff) | |
download | gitlab-ce-546ddc3f6ac96fdf09934390a938bb391d07dc94.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') |