mongoid-auditor 0.1.0 → 0.1.1
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: 2aa7ebf81ba4781aef853bf48e5fa096de08e532df7744c0bb2de5084e9b9bfb
|
|
4
|
+
data.tar.gz: 75f6100cf88e0490121e6758c08c690685136da4a0c7d96ab1f39055bccef9e7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e92739869c96d293ed5a8faa1ec7089546a4a4975e5e645dad1cf3451d1722299a438619e4b3e6617b375f60248a92b77e9b0738b37419b797b634697f906f86
|
|
7
|
+
data.tar.gz: ef29f674dd7d5a5a43ff289709f715e8b386131d405311cf0bd33818bcd3c9343dd204a0d87e3a52118341c0050d774656e167ea0b2c2dbccdca37d3252fc108
|
data/CHANGELOG.md
CHANGED
|
@@ -11,7 +11,7 @@ module Mongoid
|
|
|
11
11
|
|
|
12
12
|
class_methods do
|
|
13
13
|
# All audit logs that represent errors
|
|
14
|
-
def
|
|
14
|
+
def audit_errors
|
|
15
15
|
where(has_error: true)
|
|
16
16
|
end
|
|
17
17
|
|
|
@@ -37,22 +37,22 @@ module Mongoid
|
|
|
37
37
|
|
|
38
38
|
# Errors created today
|
|
39
39
|
def errors_today
|
|
40
|
-
|
|
40
|
+
audit_errors.where(created_at: Time.current.all_day)
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
# Errors created in last N days
|
|
44
44
|
def errors_last(days)
|
|
45
|
-
|
|
45
|
+
audit_errors.where(:created_at.gte => days.days.ago)
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
# Errors by specific actor
|
|
49
49
|
def errors_by(actor_id)
|
|
50
|
-
|
|
50
|
+
audit_errors.where(actor: actor_id)
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
# Quick summary: class names and counts
|
|
54
54
|
def error_summary
|
|
55
|
-
|
|
55
|
+
audit_errors.group_by { |log| log.error&.dig('class') || 'Unknown' }.transform_values(&:count)
|
|
56
56
|
end
|
|
57
57
|
|
|
58
58
|
def error_summary_today
|
|
@@ -41,7 +41,7 @@ module Mongoid
|
|
|
41
41
|
::Mongoid::Auditor::AuditLog.where(model_type: self.class.name, event: event, created_at: today_time)
|
|
42
42
|
end
|
|
43
43
|
|
|
44
|
-
def
|
|
44
|
+
def audit_error
|
|
45
45
|
::Mongoid::Auditor::AuditLog.where(model_id: id.to_s, model_type: self.class.name, has_error: true)
|
|
46
46
|
end
|
|
47
47
|
|