change the way we set the finished_at on batch operation job to fix alert display bug
This commit is contained in:
parent
b93b8a7230
commit
d0a131dc55
5 changed files with 39 additions and 26 deletions
|
@ -1,6 +1,12 @@
|
|||
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
|
||||
|
@ -17,4 +23,10 @@ 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,7 +95,6 @@ class BatchOperation < ApplicationRecord
|
|||
def track_processed_dossier(success, dossier)
|
||||
dossiers.delete(dossier)
|
||||
touch(:run_at) if called_for_first_time?
|
||||
touch(:finished_at) if called_for_last_time?(dossier)
|
||||
|
||||
if success
|
||||
dossier_operation(dossier).done!
|
||||
|
@ -124,10 +123,6 @@ class BatchOperation < ApplicationRecord
|
|||
run_at.nil?
|
||||
end
|
||||
|
||||
def called_for_last_time?(dossier_to_ignore)
|
||||
dossiers.count.zero?
|
||||
end
|
||||
|
||||
def total_count
|
||||
dossier_operations.size
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue