better_record 0.23.6 → 0.25.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/better_record/base.rb +3 -0
- data/app/models/better_record/logged_action.rb +1 -40
- data/app/models/better_record/model_concerns/logged_action_base.rb +50 -0
- data/app/models/better_record/table_size.rb +0 -6
- data/lib/better_record/fake_redis.rb +1 -0
- data/lib/better_record/polymorphic_override.rb +2 -2
- data/lib/better_record/version.rb +1 -1
- data/lib/core_ext/array.rb +1 -1
- metadata +25 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad1c5b656bfbdc9dc2c7271768e7083440dc0cc9a97163ddb0c91e91f6526d95
|
4
|
+
data.tar.gz: eafd3cb9a6b73c444534bcc7bea157eed7805ac8477b6d328e9e6decb7b8c61a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f37d95287b66c9bc96ee863e10edb4708ce60d6a320190a9e1e7b82141fe0d233eb1dd0c5576c4ec62483cb91ea1838532ed5ad3cb595c5edfe7868b7a05d5ce
|
7
|
+
data.tar.gz: bf5003d83eceb84b19d9491615bda612b95dbe29a0454f084b5493201fc55d597d670a463a477ae78a0773347626e453aa78d1d49cddce040568b93cfb63716e
|
@@ -29,10 +29,13 @@ 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
|
34
36
|
rescue ActiveRecord::StatementInvalid
|
35
37
|
self.const_set(:LoggedAction, BetterRecord::LoggedAction)
|
38
|
+
self
|
36
39
|
end
|
37
40
|
|
38
41
|
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
|
@@ -23,7 +23,7 @@ module BetterRecord
|
|
23
23
|
$!.message, $!.backtrace if debug
|
24
24
|
|
25
25
|
if type_val == :table_name_without_schema
|
26
|
-
type_val = klass.table_name.to_s.split('.').
|
26
|
+
type_val = klass.table_name.to_s.split('.').last
|
27
27
|
else
|
28
28
|
type_val = klass.polymorphic_name
|
29
29
|
end
|
@@ -50,7 +50,7 @@ module BetterRecord
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
p "Present Polymorphic Values:", values if debug
|
53
|
-
values
|
53
|
+
values.uniq
|
54
54
|
end
|
55
55
|
end
|
56
56
|
end
|
data/lib/core_ext/array.rb
CHANGED
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.1
|
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:
|
11
|
+
date: 2020-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: '5'
|
20
20
|
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 5.2.
|
22
|
+
version: 5.2.4
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: '5'
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 5.2.
|
32
|
+
version: 5.2.4
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: pg
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -59,7 +59,7 @@ dependencies:
|
|
59
59
|
version: '0.0'
|
60
60
|
- - ">="
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: 0.0.
|
62
|
+
version: 0.0.19
|
63
63
|
type: :runtime
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -69,7 +69,7 @@ dependencies:
|
|
69
69
|
version: '0.0'
|
70
70
|
- - ">="
|
71
71
|
- !ruby/object:Gem::Version
|
72
|
-
version: 0.0.
|
72
|
+
version: 0.0.19
|
73
73
|
- !ruby/object:Gem::Dependency
|
74
74
|
name: pry-rails
|
75
75
|
requirement: !ruby/object:Gem::Requirement
|
@@ -154,42 +154,42 @@ dependencies:
|
|
154
154
|
name: csv
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
|
-
- - ">="
|
158
|
-
- !ruby/object:Gem::Version
|
159
|
-
version: 3.0.0
|
160
157
|
- - "~>"
|
161
158
|
- !ruby/object:Gem::Version
|
162
159
|
version: '3.0'
|
160
|
+
- - ">="
|
161
|
+
- !ruby/object:Gem::Version
|
162
|
+
version: 3.1.2
|
163
163
|
type: :runtime
|
164
164
|
prerelease: false
|
165
165
|
version_requirements: !ruby/object:Gem::Requirement
|
166
166
|
requirements:
|
167
|
-
- - ">="
|
168
|
-
- !ruby/object:Gem::Version
|
169
|
-
version: 3.0.0
|
170
167
|
- - "~>"
|
171
168
|
- !ruby/object:Gem::Version
|
172
169
|
version: '3.0'
|
170
|
+
- - ">="
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: 3.1.2
|
173
173
|
- !ruby/object:Gem::Dependency
|
174
174
|
name: rspec-rails
|
175
175
|
requirement: !ruby/object:Gem::Requirement
|
176
176
|
requirements:
|
177
|
-
- - "~>"
|
178
|
-
- !ruby/object:Gem::Version
|
179
|
-
version: '3.7'
|
180
177
|
- - ">="
|
181
178
|
- !ruby/object:Gem::Version
|
182
|
-
version: 3.
|
179
|
+
version: 3.9.0
|
180
|
+
- - "~>"
|
181
|
+
- !ruby/object:Gem::Version
|
182
|
+
version: '3.9'
|
183
183
|
type: :development
|
184
184
|
prerelease: false
|
185
185
|
version_requirements: !ruby/object:Gem::Requirement
|
186
186
|
requirements:
|
187
|
-
- - "~>"
|
188
|
-
- !ruby/object:Gem::Version
|
189
|
-
version: '3.7'
|
190
187
|
- - ">="
|
191
188
|
- !ruby/object:Gem::Version
|
192
|
-
version: 3.
|
189
|
+
version: 3.9.0
|
190
|
+
- - "~>"
|
191
|
+
- !ruby/object:Gem::Version
|
192
|
+
version: '3.9'
|
193
193
|
- !ruby/object:Gem::Dependency
|
194
194
|
name: factory_bot_rails
|
195
195
|
requirement: !ruby/object:Gem::Requirement
|
@@ -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
|
@@ -360,8 +361,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
360
361
|
- !ruby/object:Gem::Version
|
361
362
|
version: '0'
|
362
363
|
requirements: []
|
363
|
-
rubygems_version: 3.0.
|
364
|
-
signing_key:
|
364
|
+
rubygems_version: 3.0.3
|
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
|