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 +4 -4
- data/lib/batch_processor/batch_job.rb +12 -5
- data/lib/batch_processor/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b84438490d8878c15ac50c47cd794492ba09b242416925901ec9e0bfb0cf9d5c
|
4
|
+
data.tar.gz: 718bb854458479e297dae9b902d76a2e03bba68cbf53054ff2726c894e346564
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|