active-audit 0.2.2 → 0.2.3
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 +4 -4
- data/lib/active_audit/audit.rb +2 -2
- data/lib/active_audit/storage_adapters/active_record_adapter.rb +3 -3
- data/lib/active_audit/storage_adapters/elasticsearch_adapter.rb +1 -1
- data/lib/active_audit/sweeper.rb +1 -1
- data/lib/generators/active_audit/templates/migration.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 260709ac6610447a1136f991de13c1f7346489fe
|
4
|
+
data.tar.gz: f4afc320cd3e63594516287417e40c4d5b6c5100
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2c85b681188d5cc6bbf9ad65a90a5db0e688ed3e65297189f1b7479347b1eed1d5ee016bac78cee78ceb57ef4d52a910ead66dd099424c630b3830725c99cd4
|
7
|
+
data.tar.gz: 1996b6c669c9626f7010b8c0f9dff07e3c92b56ba1de68f9665e8af514ef51f6b3460b014adbad33cba003d66242d6762e3ce483effe5bd394fbf58c5ed7d87c
|
data/lib/active_audit/audit.rb
CHANGED
@@ -15,13 +15,13 @@ module ActiveAudit
|
|
15
15
|
attribute :event, String
|
16
16
|
attribute :type, String
|
17
17
|
attribute :changes, Hash
|
18
|
-
attribute :
|
18
|
+
attribute :attributed_to, Hash, default: lambda {|o,a| ActiveAudit.default_user }
|
19
19
|
attribute :comment, String
|
20
20
|
attribute :recorded_at, Time, default: lambda { |o,a| Time.now.utc }
|
21
21
|
|
22
22
|
before_save do
|
23
23
|
self.recorded_at = Time.at(self.recorded_at) if self.recorded_at.is_a? Integer
|
24
|
-
self.
|
24
|
+
self.attributed_to = ActiveAudit.extract_user_profile.call(self.attributed_to) unless self.attributed_to.nil? || self.attributed_to.is_a?(Hash)
|
25
25
|
end
|
26
26
|
|
27
27
|
def initialize *args
|
@@ -12,13 +12,13 @@ module ActiveAudit
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def save audit
|
15
|
-
@connection.exec_query('INSERT INTO audits("item_id", "event", "type", "changes", "user_id", "
|
15
|
+
@connection.exec_query('INSERT INTO audits("item_id", "event", "type", "changes", "user_id", "attributed_to", "comment", "recorded_at") VALUES ($1,$2,$3,$4,$5,$6,$7,$8);', nil, [
|
16
16
|
[nil, audit.item_id],
|
17
17
|
[nil, audit.event],
|
18
18
|
[nil, audit.type],
|
19
19
|
[nil, audit.changes.to_json],
|
20
|
-
[nil, audit.
|
21
|
-
[nil, audit.
|
20
|
+
[nil, audit.attributed_to[:id]],
|
21
|
+
[nil, audit.attributed_to.to_json],
|
22
22
|
[nil, audit.comment],
|
23
23
|
[nil, audit.recorded_at]
|
24
24
|
])
|
@@ -27,7 +27,7 @@ module ActiveAudit
|
|
27
27
|
indexes :item_id, type: "long"
|
28
28
|
indexes :event, type: "string", index: "not_analyzed"
|
29
29
|
indexes :changes, type: "object", dynamic: true
|
30
|
-
indexes :
|
30
|
+
indexes :attributed_to, type: "object", properties: {
|
31
31
|
id: { type: "long" },
|
32
32
|
name: {type: "string", index: "not_analyzed"}
|
33
33
|
}
|
data/lib/active_audit/sweeper.rb
CHANGED
@@ -17,7 +17,7 @@ module ActiveAudit
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def before_create audit
|
20
|
-
audit.
|
20
|
+
audit.attributed_to = self.user if self.user
|
21
21
|
audit.comment = controller.params[:comment] if controller.respond_to?(:params, true)
|
22
22
|
audit.comment ||= ActiveAudit.session[:comment]
|
23
23
|
end
|
@@ -6,7 +6,7 @@ class <%= migration_class_name %> < ActiveRecord::Migration
|
|
6
6
|
t.column :event, :string
|
7
7
|
t.column :changes, :json
|
8
8
|
t.column :user_id, :integer
|
9
|
-
t.column :
|
9
|
+
t.column :attributed_to, :json
|
10
10
|
t.column :comment, :string
|
11
11
|
t.column :recorded_at, :datetime
|
12
12
|
end
|