summaryrefslogtreecommitdiff
path: root/app/models/audit_event.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-02-20 13:49:51 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-02-20 13:49:51 +0000
commit71786ddc8e28fbd3cb3fcc4b3ff15e5962a1c82e (patch)
tree6a2d93ef3fb2d353bb7739e4b57e6541f51cdd71 /app/models/audit_event.rb
parenta7253423e3403b8c08f8a161e5937e1488f5f407 (diff)
downloadgitlab-ce-71786ddc8e28fbd3cb3fcc4b3ff15e5962a1c82e.tar.gz
Add latest changes from gitlab-org/gitlab@15-9-stable-eev15.9.0-rc42
Diffstat (limited to 'app/models/audit_event.rb')
-rw-r--r--app/models/audit_event.rb14
1 files changed, 8 insertions, 6 deletions
diff --git a/app/models/audit_event.rb b/app/models/audit_event.rb
index 5cc87be388f..3312216932b 100644
--- a/app/models/audit_event.rb
+++ b/app/models/audit_event.rb
@@ -55,7 +55,7 @@ class AuditEvent < ApplicationRecord
end
def initialize_details
- return unless self.has_attribute?(:details)
+ return unless has_attribute?(:details)
self.details = {} if details&.nil?
end
@@ -65,7 +65,9 @@ class AuditEvent < ApplicationRecord
end
def formatted_details
- details.merge(details.slice(:from, :to).transform_values(&:to_s))
+ details
+ .merge(details.slice(:from, :to).transform_values(&:to_s))
+ .merge(author_email: author.try(:email))
end
def author
@@ -74,7 +76,7 @@ class AuditEvent < ApplicationRecord
def lazy_author
BatchLoader.for(author_id).batch do |author_ids, loader|
- User.select(:id, :name, :username).where(id: author_ids).find_each do |user|
+ User.select(:id, :name, :username, :email).where(id: author_ids).find_each do |user|
loader.call(user.id, user)
end
end
@@ -82,7 +84,7 @@ class AuditEvent < ApplicationRecord
def as_json(options = {})
super(options).tap do |json|
- json['ip_address'] = self.ip_address.to_s
+ json['ip_address'] = ip_address.to_s
end
end
@@ -114,10 +116,10 @@ class AuditEvent < ApplicationRecord
def parallel_persist
PARALLEL_PERSISTENCE_COLUMNS.each do |name|
- original = self[name] || self.details[name]
+ original = self[name] || details[name]
next unless original
- self[name] = self.details[name] = original
+ self[name] = details[name] = original
end
end