batch_processor 0.2.4 → 0.2.5

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: d8f0faec9d505307050df1903ac8804fe7978a6b02fb6244955a1e421775002a
4
- data.tar.gz: 326e449ba11aedb79606c2b47aa232b4205724a6822cdbb709b65f3b8177674f
3
+ metadata.gz: b84438490d8878c15ac50c47cd794492ba09b242416925901ec9e0bfb0cf9d5c
4
+ data.tar.gz: 718bb854458479e297dae9b902d76a2e03bba68cbf53054ff2726c894e346564
5
5
  SHA512:
6
- metadata.gz: 1e0201cbb2edb12428adb676f2b19177a83153de3612372f8d80755bd3278ecf222ab44107835c2d16c6629be6109f2685f5bc4fdc7364fa04ba4d9187979109
7
- data.tar.gz: 5c97dae7e460fc3e1e19216befee5b1e09a1d91a540150ce232722898fda74b217c72023a7534e5e54e2d51031a3a9bc1c8ada21d88f498de499ff6f9a0b927b
6
+ metadata.gz: 5822bc83e28b613c5e211606d75f015fedb66a5d0cce955f815a866a73cc4f460d7ebdb59b98dbf84573979619cf4f995c4cbab4b2ec7c4317f42c16852a61dc
7
+ data.tar.gz: e7223742d5e6dd841a6ae633c7a91f5a94ee597d6caeafd3df19aec8415897f192ef5da8da16e68fd7de63c57727dadbe86ae462097346e2b691e1ca1bb60ca9
@@ -3,7 +3,7 @@
3
3
  # A batch can only be processed by a batchable job.
4
4
  module BatchProcessor
5
5
  class BatchJob < ActiveJob::Base
6
- attr_accessor :batch_id
6
+ attr_accessor :batch_id, :tracked_batch_running
7
7
 
8
8
  include Technologic
9
9
 
@@ -20,6 +20,8 @@ module BatchProcessor
20
20
  before_perform(if: :batch_job?) do
21
21
  raise BatchAbortedError if batch.aborted?
22
22
 
23
+ self.tracked_batch_running = true
24
+
23
25
  batch.job_running
24
26
  end
25
27
 
@@ -28,10 +30,7 @@ module BatchProcessor
28
30
  def rescue_with_handler(exception)
29
31
  batch.job_canceled and return exception if exception.is_a?(BatchAbortedError)
30
32
 
31
- if batch_job?
32
- error :batch_job_failed, exception: exception, job_id: job_id
33
- batch.job_failure
34
- end
33
+ batch_job_failure(exception) if batch_job?
35
34
 
36
35
  super
37
36
  end
@@ -60,5 +59,13 @@ module BatchProcessor
60
59
  def batch_job?
61
60
  batch_id.present?
62
61
  end
62
+
63
+ private
64
+
65
+ def batch_job_failure(exception)
66
+ error :batch_job_failed, exception: exception, job_id: job_id
67
+ batch.job_running unless tracked_batch_running
68
+ batch.job_failure
69
+ end
63
70
  end
64
71
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BatchProcessor
4
- VERSION = "0.2.4"
4
+ VERSION = "0.2.5"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: batch_processor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Garside