inboxable 0.1.1 → 0.1.2

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: 7f796060bcb2461754d9c77a51ca4b5dfa638d3e5235af50be6ed58195187bd6
4
- data.tar.gz: 8671ce2b6c55b7d1060466de3280ec066e407f5bd2c8fc617ee83c104034237d
3
+ metadata.gz: b4d81533a77f953ec0b2e7b5b7b86dee4da59cfec008aedad5a9234a8303d7dd
4
+ data.tar.gz: ac85e6bb520fed77412e3c233dd6ac9385f828244f744d79da820a964c3f2e55
5
5
  SHA512:
6
- metadata.gz: 2a63084c541d6da7d74c3b8fbfa8277574c7931d713dd4591cdc4043034391ed96eb51fa4b0a090c4e3bb551bc5e2d6b6c5b045f86e5af8d735b4dc2874d5c9b
7
- data.tar.gz: ed83bb53ec33b7f8d32052c7216c8b3cf9573f9a373a709704fef6a214eca03fa5bd000bb802bb476d547fbffe274694e7ed3b02f24f13f382e32b093f225741
6
+ metadata.gz: 84cbdd6b4070185a8ce0322225c76b4490b0ec78e415c924c47ba0bc0c0a632170e9ba946a17cebb992b372422cd2a3ef05890b8a6baeb8f67e365779539c007
7
+ data.tar.gz: ad3d25d9823c1a45288c49b402b2f92de3ff519415a02bbe3a40ced00b8c2f2316e795e6282911869c8136158552be696caa26d52543c5fbb288edb93184269d
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
- ## [Unreleased]
1
+ # Changelog
2
+ This file is used to list changes made in each version of the inboxable gem.
2
3
 
3
- ## [0.1.1] - 2024-01-21
4
+ ## Inboxable 0.1.2 (2024-01-22)
4
5
 
5
- - Initial release
6
+ * Added scope for each status key in the `Inbox` model to fetch the
7
+ corresponding records.
8
+
9
+ ## Inboxable 0.1.1 (2024-01-22)
10
+
11
+ * Added `inbox_model` configuration to the `Configuration` class to allow for custom
12
+ inbox models.
13
+
14
+ ## Inboxable 0.1.0 (2024-01-22)
15
+
16
+ * Initial release
data/README.md CHANGED
@@ -80,7 +80,9 @@ The options are as follows:
80
80
 
81
81
  ## Inbox Model
82
82
 
83
- The Inbox model is used to store the messages in the inbox. The Inbox model is generated by the gem when you run the `rails g inboxable:install --orm <orm>` command. Based on the ORM that you are using, the gem will generate the appropriate model. The following is the structure of the Inbox model for ActiveRecord and Mongoid.
83
+ The Inbox model is used to store the messages in the inbox. The Inbox model is generated by the gem when you run the `rails g inboxable:install --orm <orm>` command. Based on the ORM that you are using, the gem will generate the appropriate model.The following is the structure of the Inbox model for ActiveRecord and Mongoid.
84
+
85
+ If you would like to use a different name for the Inbox model. You can configure it by setting the `inbox_model` config to the name of you custom defined model. See the [Configuration](#configuration) section below for more information.
84
86
 
85
87
  ### Fields & Attributes
86
88
 
@@ -123,7 +125,8 @@ The Inboxable gem provides a number of configuration options that can be used to
123
125
  ---
124
126
  | Option | Description | Default Value | Applied To |
125
127
  | --- | --- |------------------|---|
126
- | `orm` | The ORM that is used in the application. | `:active_record` | `/config/initializers/inboxable.rb` |
128
+ | `orm` | The ORM that is used in the application. | `:active_record` | `/config/initializers/z_inboxable.rb` |
129
+ | `inbox_model` | The name of the Inbox model. | `Inbox` | `/config/initializers/z_inboxable.rb` |
127
130
  |`INBOXABLE__CRON_POLL_INTERVAL` | The interval in seconds between each poll of the inbox. | `5` | Can be overridden by providing an environment variable with the same name. |
128
131
  |`INBOXABLE__CRON` | The cron expression that is used to poll the inbox. | `*/5 * * * * *` | Can be overridden by providing an environment variable with the same name. |
129
132
  |`INBOXABLE__BATCH_SIZE` | The number of messages to be processed in each batch. | `100` | Can be overridden by providing an environment variable with the same name. |
@@ -10,9 +10,9 @@ module Inboxable
10
10
 
11
11
  def perform_activerecord
12
12
  Inboxable.inbox_model.pending
13
- .where(last_attempted_at: [..Time.zone.now, nil])
14
- .find_in_batches(batch_size: ENV.fetch('INBOXABLE__BATCH_SIZE', 100).to_i)
15
- .each do |batch|
13
+ .where(last_attempted_at: [..Time.zone.now, nil])
14
+ .find_in_batches(batch_size: ENV.fetch('INBOXABLE__BATCH_SIZE', 100).to_i)
15
+ .each do |batch|
16
16
  batch.each do |inbox|
17
17
  inbox.processor_class_name.constantize.perform_async(inbox.id)
18
18
  inbox.update(last_attempted_at: 1.minute.from_now, status: :processed, allow_processing: false)
@@ -23,8 +23,8 @@ module Inboxable
23
23
  def perform_mongoid
24
24
  batch_size = ENV.fetch('INBOXABLE__BATCH_SIZE', 100).to_i
25
25
  Inboxable.inbox_model.pending
26
- .any_of({ last_attempted_at: ..Time.zone.now }, { last_attempted_at: nil })
27
- .each_slice(batch_size) do |batch|
26
+ .any_of({ last_attempted_at: ..Time.zone.now }, { last_attempted_at: nil })
27
+ .each_slice(batch_size) do |batch|
28
28
  batch.each do |inbox|
29
29
  inbox.processor_class_name.constantize.perform_async(inbox.id.to_s)
30
30
  inbox.update(last_attempted_at: 1.minute.from_now, status: :processed, allow_processing: false)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Inboxable
4
- VERSION = '0.1.1'
4
+ VERSION = '0.1.2'
5
5
  end
@@ -19,6 +19,10 @@ class Inbox
19
19
 
20
20
  as_enum :status, %i[pending processed failed], field: { type: String, default: 'pending' }, map: :string
21
21
 
22
+ statuses.each_key do |key|
23
+ scope key, -> { where(status_cd: key) }
24
+ end
25
+
22
26
  validates :processor_class_name, presence: true
23
27
 
24
28
  after_create :process, if: proc { |resource| resource.allow_processing == true }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inboxable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Muhammad Nawzad