Overload the finished_at
This commit is contained in:
parent
d0a131dc55
commit
120fbb0ef7
5 changed files with 26 additions and 39 deletions
|
@ -1,12 +1,6 @@
|
|||
class BatchOperationProcessOneJob < ApplicationJob
|
||||
retry_on StandardError, attempts: 1 # default 5, for now no retryable behavior
|
||||
|
||||
after_perform do |job|
|
||||
if called_for_last_time?(job)
|
||||
job.arguments.first.touch(:finished_at)
|
||||
end
|
||||
end
|
||||
|
||||
def perform(batch_operation, dossier)
|
||||
dossier = batch_operation.dossiers_safe_scope.find(dossier.id)
|
||||
begin
|
||||
|
@ -23,10 +17,4 @@ class BatchOperationProcessOneJob < ApplicationJob
|
|||
rescue ActiveRecord::RecordNotFound
|
||||
dossier.update_column(:batch_operation_id, nil)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def called_for_last_time?(job)
|
||||
job.arguments.first.dossiers.count.zero?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -95,6 +95,7 @@ class BatchOperation < ApplicationRecord
|
|||
def track_processed_dossier(success, dossier)
|
||||
dossiers.delete(dossier)
|
||||
touch(:run_at) if called_for_first_time?
|
||||
touch(:finished_at)
|
||||
|
||||
if success
|
||||
dossier_operation(dossier).done!
|
||||
|
@ -139,6 +140,10 @@ class BatchOperation < ApplicationRecord
|
|||
dossier_operations.error.present?
|
||||
end
|
||||
|
||||
def finished_at
|
||||
dossiers.empty? ? run_at : nil
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def dossier_operation(dossier)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue