summaryrefslogtreecommitdiff
path: root/app/models/audit_event.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-02-18 10:34:06 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-02-18 10:34:06 +0000
commit859a6fb938bb9ee2a317c46dfa4fcc1af49608f0 (patch)
treed7f2700abe6b4ffcb2dcfc80631b2d87d0609239 /app/models/audit_event.rb
parent446d496a6d000c73a304be52587cd9bbc7493136 (diff)
downloadgitlab-ce-859a6fb938bb9ee2a317c46dfa4fcc1af49608f0.tar.gz
Add latest changes from gitlab-org/gitlab@13-9-stable-eev13.9.0-rc42
Diffstat (limited to 'app/models/audit_event.rb')
-rw-r--r--app/models/audit_event.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/app/models/audit_event.rb b/app/models/audit_event.rb
index d1c0bb11dc8..32c9d44f836 100644
--- a/app/models/audit_event.rb
+++ b/app/models/audit_event.rb
@@ -55,15 +55,20 @@ class AuditEvent < ApplicationRecord
end
def author_name
- lazy_author.name
+ author&.name
end
def formatted_details
details.merge(details.slice(:from, :to).transform_values(&:to_s))
end
+ def author
+ lazy_author&.itself.presence ||
+ ::Gitlab::Audit::NullAuthor.for(author_id, (self[:author_name] || details[:author_name]))
+ end
+
def lazy_author
- BatchLoader.for(author_id).batch(default_value: default_author_value, replace_methods: false) do |author_ids, loader|
+ BatchLoader.for(author_id).batch(replace_methods: false) do |author_ids, loader|
User.select(:id, :name, :username).where(id: author_ids).find_each do |user|
loader.call(user.id, user)
end