Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-03 15:09:52 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-03 15:09:52 +0300
commit546ddc3f6ac96fdf09934390a938bb391d07dc94 (patch)
treed0c92fca27ee76b5a20b7bfb56bda6f057424127 /app/models
parent04baa85554ff13bdd4d6f4e6bb24119d17608fee (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models')
-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')