diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-22 11:31:16 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-22 11:31:16 +0000 |
commit | 905c1110b08f93a19661cf42a276c7ea90d0a0ff (patch) | |
tree | 756d138db422392c00471ab06acdff92c5a9b69c /app/models/audit_event.rb | |
parent | 50d93f8d1686950fc58dda4823c4835fd0d8c14b (diff) | |
download | gitlab-ce-905c1110b08f93a19661cf42a276c7ea90d0a0ff.tar.gz |
Add latest changes from gitlab-org/gitlab@12-4-stable-ee
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') |