batches_task_processor 0.3.4 → 0.3.5

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: 55fa72604c911bc9aea067d0d517b3915d50a961aa2b3dc58f55aa0abf137821
4
- data.tar.gz: b7af4ba8d405b7f5261740b1c1c49283b3f1bb6d5ecfd46f1a03ee22c230e4cf
3
+ metadata.gz: 69f248153b65e49d24ebbebaa064cb3f5e03aec503cb2d2b9add636c96e8aad4
4
+ data.tar.gz: d020b38e7e8fea12d7a7df841ca976881ab86b7dee326f3befd4ccc94d205033
5
5
  SHA512:
6
- metadata.gz: 448ede71fdf8000fb9e0a7f38c00b8ab4eb25c1600844bb0e7f6c592e19fabe5fae0f147a0a3c2773f7302d0069e59bbe33815e4602890898d0d05c4d724a486
7
- data.tar.gz: '081e7b82550eb9f6d222fc28275540cbda005a42b7485dd9f296c6dadc9a59844ceed3e47f1f891e240626d3877c9a519e4615bfc5ca385400b552fe56fccc83'
6
+ metadata.gz: 0bfdfae31beed3d6bb7ea8c3004f842bd5936a94d9f188ebfaeb573c44f38207aeef2ea343bc9db848ce66c50e1ff27d9da4c5a261f98b783c95551e7a3f7059
7
+ data.tar.gz: 4219b4010280239086ee4a9dabe50876a495f599f2d4450227cd8c8dac105ae9e798aa7e2348838b52b8e9c7f78a61aded822e334f9674cca5c1edb92cd8784a
@@ -41,6 +41,10 @@ module BatchesTaskProcessor
41
41
  Rails.logger.info "Process status: #{items.count}/#{data.count}"
42
42
  end
43
43
 
44
+ def retry_failures
45
+ start!
46
+ end
47
+
44
48
  def export
45
49
  filename = (key || 'batches_task_processor_result').try(:parameterize)
46
50
  path = Rails.root.join("tmp/#{filename}.csv")
@@ -55,7 +55,7 @@ module BatchesTaskProcessor
55
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
- next log("Skipping #{key}...") if already_processed?(key)
58
+ next if already_processed?(key)
59
59
 
60
60
  start_process_item(item, job, key, index)
61
61
  end
@@ -72,14 +72,14 @@ module BatchesTaskProcessor
72
72
  def start_process_item(item, job, key, index)
73
73
  log "Processing key: #{key}, job: #{job}, counter: #{index}/#{task_model.qty_items_job}"
74
74
  result = process_item(item)
75
- task_model.items.create!(key: key, result: result.to_s[0..255])
75
+ task_model.items.where(key: key).first_or_initialize.update!(result: result, error_details: nil)
76
76
  rescue => e
77
- task_model.items.create!(key: key, error_details: e.message)
77
+ task_model.items.where(key: key).first_or_initialize.update!(result: nil, error_details: e.message)
78
78
  log "Process failed #{job}/#{key}: #{e.message}"
79
79
  end
80
80
 
81
81
  def already_processed?(key)
82
- task_model.items.where(key: key).exists?
82
+ task_model.items.where(key: key, error_details: nil).exists?
83
83
  end
84
84
 
85
85
  def process_cancelled?
@@ -1,3 +1,3 @@
1
1
  module BatchesTaskProcessor
2
- VERSION = "0.3.4"
2
+ VERSION = "0.3.5"
3
3
  end
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.4
4
+ version: 0.3.5
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-16 00:00:00.000000000 Z
11
+ date: 2022-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails