batches_task_processor 0.3.2 → 0.3.3

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: 9e3ca93ca15247aafcea0afc6873b11bc26d8519e7b5ef477ceefd9174552888
4
- data.tar.gz: e2669c5ed9c3f8afdefa0d5e59ee7750437560d95b78792dfa5c43da2edbbf1e
3
+ metadata.gz: 35e87c4ae1e2728db3bf365e2bb9ceb74aa7d5605bc5fbf5a94aea4fd9559637
4
+ data.tar.gz: 65da53cfe48a3aedc8eece776e3100edb5d4d1e29a2b0b99123a6f50f0aa5ee2
5
5
  SHA512:
6
- metadata.gz: 140fa98d409be395a422f2687d64d0690b1b65ae1ded1cd7e00e2b0d3217680c65b8629b7aea8da5b38dd6b62fb79acd8631ae250bfe262121b1107466b65f16
7
- data.tar.gz: e594672fb7e890d0e475f7480f6b503c34d64fc4525c50c6bfe47909b1c4b573ab6af62db13140d847cd6a5ce49332e42d7b3ea8db75d5931d27b284dea41b99
6
+ metadata.gz: 6c2a0f73cd1385dba738cc8a09c2159889f067d9e9743f33bae49feb4085c41b49293599b70241a31bdc9612c52e26a31568a56f69ef51b428a9855df7ed3f60
7
+ data.tar.gz: bc945ab30a45c47d0519380cd85efd5c15534c7ba5eb1915deed65777ce3e88aa95910311fbdc64d1e7623e085d6c1857bd305e6261f6effc24e5ee367dd2887
data/README.md CHANGED
@@ -18,8 +18,12 @@ And then execute: `bundle install && bundle exec rake db:migrate`
18
18
  key: 'my_process',
19
19
  data: Article.all.limit(200000).pluck(:id),
20
20
  qty_jobs: 10,
21
+ queue_name: 'default',
21
22
  preload_job_items: 'Article.where(id: items)',
22
- process_item: 'puts "my article ID: #{item.id}"'
23
+ process_item: %{
24
+ puts "Processing article #{item.id}..."
25
+ HugeArticleProcessor.new(item).call
26
+ }
23
27
  )
24
28
  task.start!
25
29
  ```
@@ -7,8 +7,8 @@ module BatchesTaskProcessor
7
7
  has_many :items, class_name: 'BatchesTaskProcessor::ModelItem', dependent: :destroy, foreign_key: :batches_task_processors_id
8
8
  validates :process_item, presence: true
9
9
  validates :key, presence: true
10
- before_create :apply_data_uniqueness
11
- before_create :check_qty_jobs
10
+ before_save :apply_data_uniqueness
11
+ before_save :check_qty_jobs
12
12
  # state: :pending, :processing, :finished, :canceled
13
13
 
14
14
  def qty_items_job
@@ -52,7 +52,7 @@ module BatchesTaskProcessor
52
52
  def run_job(job)
53
53
  log "Running ##{job} job..."
54
54
  items = job_items(job)
55
- (items.try(:find_each) || items.each).with_index do |item, index|
55
+ (items.try(:find_each) || items.each).with_index(1) do |item, index|
56
56
  key = item.try(:id) || item
57
57
  break log('Process cancelled') if process_cancelled?
58
58
  next log("Skipping #{key}...") if already_processed?(key)
@@ -1,3 +1,3 @@
1
1
  module BatchesTaskProcessor
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  end
@@ -6,7 +6,7 @@ class AddBatchesTaskProcessor < ActiveRecord::Migration[5.0]
6
6
  t.string :key
7
7
  t.string :state, default: :pending
8
8
  t.json :data, default: [] if support_json?
9
- t.text :data unless support_json?
9
+ t.text :data, limit: 999999 unless support_json?
10
10
  t.integer :qty_jobs, default: 10
11
11
  t.datetime :finished_at
12
12
  t.text :preload_job_items
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: batches_task_processor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Owen Peredo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-02 00:00:00.000000000 Z
11
+ date: 2022-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails