auto_alert 0.1.0 → 0.2.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 +4 -4
- data/README.md +2 -0
- data/lib/auto_alert/acts_as_alert.rb +6 -0
- data/lib/auto_alert/version.rb +1 -1
- data/lib/auto_alert.rb +0 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dbfbc24c0aedd6c8a32d3db487fc3f4db6dc5543417a48ffd33e5d848959dda5
|
4
|
+
data.tar.gz: d6632890303dcf249acc5b0a4f3417717b54653cbcd5a0448c8f588ce63f276b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c314f32f99e9f738a2a657ef882ee595412b8e242a12de1b29d1c60fc90197eb2edbd55e1df43640395ec8030ce0e25cbe0c67542d7cb9c7d7c3a8b598753126
|
7
|
+
data.tar.gz: 7c08e1f6f6652c08d4dbe424f9709d394c3c13487944530bda5abef05266513f2e8b1fd14adb72153cf3705994a3488f9f58165ed4b29eb16e69050c9c1f7f1a
|
data/README.md
CHANGED
@@ -109,6 +109,8 @@ class MyModel < ApplicationRecord
|
|
109
109
|
|
110
110
|
For more complicated use cases, especially where alert conditions rely on factors external to the model instance itself, it can make sense to use a [job](https://guides.rubyonrails.org/active_job_basics.html) to asynchronously call `scan_for_alerts!` on big batches of records.
|
111
111
|
|
112
|
+
You can also call the class method `scan_all_unresolved!` on your Alert model to check if any unresolved alerts should be resolved. Again, it might be best to use a job to do this periodically in the background.
|
113
|
+
|
112
114
|
|
113
115
|
### Alert records
|
114
116
|
|
@@ -6,6 +6,9 @@ module AutoAlert
|
|
6
6
|
# Class method to register a model as alertable
|
7
7
|
def acts_as_alert
|
8
8
|
belongs_to :alertable, polymorphic: true
|
9
|
+
scope :resolved, -> { where(resolved: true) }
|
10
|
+
scope :unresolved, -> { where(resolved: false) }
|
11
|
+
|
9
12
|
validates :kind,
|
10
13
|
uniqueness: {
|
11
14
|
scope: :alertable,
|
@@ -20,6 +23,9 @@ module AutoAlert
|
|
20
23
|
end
|
21
24
|
|
22
25
|
module SingletonMethods
|
26
|
+
def scan_all_unresolved!
|
27
|
+
unresolved.each { |unresolved_alert| unresolved_alert.alertable.scan_for_alerts! }
|
28
|
+
end
|
23
29
|
end
|
24
30
|
end
|
25
31
|
end
|
data/lib/auto_alert/version.rb
CHANGED
data/lib/auto_alert.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: auto_alert
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brendan Tang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -70,7 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
70
70
|
- !ruby/object:Gem::Version
|
71
71
|
version: '0'
|
72
72
|
requirements: []
|
73
|
-
rubygems_version: 3.2.
|
73
|
+
rubygems_version: 3.2.22
|
74
74
|
signing_key:
|
75
75
|
specification_version: 4
|
76
76
|
summary: Automatically raise and dismiss alerts on your ActiveRecord models.
|