better_record 0.24.4 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e14508d1f965fba3627ea9c4449b9fa99aae6dc4888d50ca184e376e0bfd7f8
|
4
|
+
data.tar.gz: b7dc73ef64bf0a4493a04bccd48c87796d388fc1f1cc51dc0aed4e70fc697ab8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa140f70f9b6e173c9db0116c81e65a5981e7156ee1ac579a4bf49605652e7e23f4b81cc040fdf1664106d65db1195dcbdff10ccee4ba051b5d40d3936f899f5
|
7
|
+
data.tar.gz: 40f4fdc3cac02693a4336c6216f3e505f06e196aea1fdf53e081dea98307b7aed1dfd188c88e68f890c22ae72704a06ceea8e226657e532ce5d1d5e90e52f8be
|
@@ -29,10 +29,14 @@ module BetterRecord
|
|
29
29
|
connection.execute(%Q(SELECT 1 FROM #{t_name}_#{self.table_name_only} LIMIT 1))
|
30
30
|
|
31
31
|
self.const_set(:LoggedAction, Class.new(ApplicationRecord))
|
32
|
+
self.const_get(:LoggedAction).include(ModelConcerns::LoggedActionBase)
|
32
33
|
self.const_get(:LoggedAction).table_name = "#{t_name}_#{self.table_name_only}"
|
33
34
|
self.const_get(:LoggedAction).primary_key = :event_id
|
35
|
+
self.const_get(:LoggedAction).first
|
36
|
+
self
|
34
37
|
rescue ActiveRecord::StatementInvalid
|
35
38
|
self.const_set(:LoggedAction, BetterRecord::LoggedAction)
|
39
|
+
self
|
36
40
|
end
|
37
41
|
|
38
42
|
self.has_many self.audit_relation_name,
|
@@ -3,27 +3,15 @@
|
|
3
3
|
module BetterRecord
|
4
4
|
class LoggedAction < Base
|
5
5
|
# == Constants ============================================================
|
6
|
-
ACTIONS = {
|
7
|
-
D: 'DELETE',
|
8
|
-
I: 'INSERT',
|
9
|
-
U: 'UPDATE',
|
10
|
-
T: 'TRUNCATE',
|
11
|
-
A: 'ARCHIVE',
|
12
|
-
}.with_indifferent_access
|
13
6
|
|
14
7
|
# == Attributes ===========================================================
|
15
8
|
self.table_name = "#{BetterRecord.db_audit_schema}.logged_actions_view"
|
16
9
|
self.primary_key = :event_id
|
17
10
|
|
18
11
|
# == Extensions ===========================================================
|
12
|
+
include ModelConcerns::LoggedActionBase
|
19
13
|
|
20
14
|
# == Relationships ========================================================
|
21
|
-
belongs_to :audited,
|
22
|
-
polymorphic: :true,
|
23
|
-
primary_type: :table_name,
|
24
|
-
foreign_key: :row_id,
|
25
|
-
foreign_type: :table_name,
|
26
|
-
optional: true
|
27
15
|
|
28
16
|
# == Validations ==========================================================
|
29
17
|
|
@@ -34,37 +22,10 @@ module BetterRecord
|
|
34
22
|
# == Boolean Class Methods ================================================
|
35
23
|
|
36
24
|
# == Class Methods ========================================================
|
37
|
-
def self.default_print
|
38
|
-
[
|
39
|
-
:event_id,
|
40
|
-
:row_id,
|
41
|
-
:full_name,
|
42
|
-
:app_user_id,
|
43
|
-
:app_user_type,
|
44
|
-
:action_type,
|
45
|
-
:changed_columns
|
46
|
-
]
|
47
|
-
end
|
48
|
-
|
49
|
-
# def self.set_audits_methods!
|
50
|
-
# self.has_many self.audit_relation_name,
|
51
|
-
# class_name: 'BetterRecord::LoggedAction',
|
52
|
-
# primary_type: :table_name,
|
53
|
-
# foreign_key: :row_id,
|
54
|
-
# foreign_type: :table_name,
|
55
|
-
# as: self.audit_relation_name
|
56
|
-
# end
|
57
25
|
|
58
26
|
# == Boolean Methods ======================================================
|
59
27
|
|
60
28
|
# == Instance Methods =====================================================
|
61
|
-
def changed_columns
|
62
|
-
(self.changed_fields || {}).keys.join(', ').presence || 'N/A'
|
63
|
-
end
|
64
|
-
|
65
|
-
def action_type
|
66
|
-
ACTIONS[action] || 'UNKNOWN'
|
67
|
-
end
|
68
29
|
|
69
30
|
end
|
70
31
|
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/concern'
|
4
|
+
|
5
|
+
module BetterRecord
|
6
|
+
module ModelConcerns
|
7
|
+
module LoggedActionBase
|
8
|
+
extend ActiveSupport::Concern
|
9
|
+
|
10
|
+
ACTIONS = {
|
11
|
+
D: 'DELETE',
|
12
|
+
I: 'INSERT',
|
13
|
+
U: 'UPDATE',
|
14
|
+
T: 'TRUNCATE',
|
15
|
+
A: 'ARCHIVE',
|
16
|
+
}.with_indifferent_access
|
17
|
+
|
18
|
+
included do
|
19
|
+
belongs_to :record,
|
20
|
+
polymorphic: :true,
|
21
|
+
primary_type: :table_name,
|
22
|
+
foreign_key: :row_id,
|
23
|
+
foreign_type: :table_name,
|
24
|
+
optional: true
|
25
|
+
end
|
26
|
+
|
27
|
+
class_methods do
|
28
|
+
def default_print
|
29
|
+
[
|
30
|
+
:event_id,
|
31
|
+
:row_id,
|
32
|
+
:full_name,
|
33
|
+
:app_user_id,
|
34
|
+
:app_user_type,
|
35
|
+
:action_type,
|
36
|
+
:changed_columns
|
37
|
+
]
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def changed_columns
|
42
|
+
(self.changed_fields || {}).keys.join(', ').presence || 'N/A'
|
43
|
+
end
|
44
|
+
|
45
|
+
def action_type
|
46
|
+
ACTIONS[action] || 'UNKNOWN'
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -85,12 +85,6 @@ module BetterRecord
|
|
85
85
|
# == Boolean Methods ======================================================
|
86
86
|
|
87
87
|
# == Instance Methods =====================================================
|
88
|
-
def changed_columns
|
89
|
-
(self.changed_fields || {}).keys.join(', ').presence || 'N/A'
|
90
|
-
end
|
91
88
|
|
92
|
-
def action_type
|
93
|
-
ACTIONS[action] || 'UNKNOWN'
|
94
|
-
end
|
95
89
|
end
|
96
90
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: better_record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.25.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sampson Crowley
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -244,6 +244,7 @@ files:
|
|
244
244
|
- app/models/better_record/logged_action.rb
|
245
245
|
- app/models/better_record/model_concerns/has_protected_password.rb
|
246
246
|
- app/models/better_record/model_concerns/has_validated_avatar.rb
|
247
|
+
- app/models/better_record/model_concerns/logged_action_base.rb
|
247
248
|
- app/models/better_record/table_size.rb
|
248
249
|
- app/views/better_record/table_sizes/index.html.erb
|
249
250
|
- app/views/better_record/table_sizes/show.html.erb
|
@@ -345,7 +346,7 @@ homepage: https://github.com/SampsonCrowley/multi_app_active_record
|
|
345
346
|
licenses:
|
346
347
|
- MIT
|
347
348
|
metadata: {}
|
348
|
-
post_install_message:
|
349
|
+
post_install_message:
|
349
350
|
rdoc_options: []
|
350
351
|
require_paths:
|
351
352
|
- lib
|
@@ -361,7 +362,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
361
362
|
version: '0'
|
362
363
|
requirements: []
|
363
364
|
rubygems_version: 3.0.3
|
364
|
-
signing_key:
|
365
|
+
signing_key:
|
365
366
|
specification_version: 4
|
366
367
|
summary: Fix functions that are lacking in Active record to be compatible with multi-app
|
367
368
|
databases
|