auto_alert 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6115b3cc9d444af3c92d33b3ad3c3152040e0912254a36959d46e732dd3e3634
4
- data.tar.gz: 2da6fae49f957aeb5be28a00dd9921feb699ad8d63ea7b83d906e073e9ba6079
3
+ metadata.gz: dbfbc24c0aedd6c8a32d3db487fc3f4db6dc5543417a48ffd33e5d848959dda5
4
+ data.tar.gz: d6632890303dcf249acc5b0a4f3417717b54653cbcd5a0448c8f588ce63f276b
5
5
  SHA512:
6
- metadata.gz: 7934f6257a750d9fa24814e3789e2c30f81c84d903d55688c8fd38a11d6c3ee11f46645cef1101fe43f29dbea8227c19538baff07987d5ae6bda92e7105fc8f7
7
- data.tar.gz: dbbb8a284baf98324de67846bc216ec48ef9912f74e09b1ef9e5120849cb6970bdf8dbe0f1bc61272532abbec2d672022db01e22ad5eec5800d8dcdee1e5d738
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
@@ -1,3 +1,3 @@
1
1
  module AutoAlert
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.0'
3
3
  end
data/lib/auto_alert.rb CHANGED
@@ -5,5 +5,4 @@ require "auto_alert/acts_as_alert"
5
5
  require "auto_alert/checker"
6
6
 
7
7
  module AutoAlert
8
- # Your code goes here...
9
8
  end
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.1.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-06-15 00:00:00.000000000 Z
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.16
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.