diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-09-26 12:06:04 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-09-26 12:06:04 +0300 |
commit | 759cd6c2985088d187ed519f2a881c2c690b34ec (patch) | |
tree | 183e291c0404bf9b3ac7638be6fa1fe94b7d2d14 /app/models/audit_event.rb | |
parent | 9735395f94088df7e6470e3e8a2638385ede36b6 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/audit_event.rb')
-rw-r--r-- | app/models/audit_event.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/app/models/audit_event.rb b/app/models/audit_event.rb index c2eef500fb0..06a607b75a4 100644 --- a/app/models/audit_event.rb +++ b/app/models/audit_event.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true class AuditEvent < ApplicationRecord + include CreatedAtFilterable + serialize :details, Hash # rubocop:disable Cop/ActiveRecordSerialize belongs_to :user, foreign_key: :author_id @@ -9,6 +11,9 @@ class AuditEvent < ApplicationRecord validates :entity_id, presence: true validates :entity_type, presence: true + scope :by_entity_type, -> (entity_type) { where(entity_type: entity_type) } + scope :by_entity_id, -> (entity_id) { where(entity_id: entity_id) } + after_initialize :initialize_details def initialize_details @@ -18,6 +23,10 @@ class AuditEvent < ApplicationRecord def author_name self.user.name end + + def formatted_details + details.merge(details.slice(:from, :to).transform_values(&:to_s)) + end end AuditEvent.prepend_if_ee('EE::AuditEvent') |