Know in the batch-finished-callback which exact jobs in the batch failed #1187
-
I have a batch of jobs running as a batch with an on-finished callback-job. I'd like this callback-job to inform the admin about how many and which exact jobs in the batch failed. I have tried to access some attribute of the job instances in class MyUpdateCallbackJob < ApplicationJob
queue_as :updates
def perform(batch, params)
discarded_jobs = bulk.active_jobs.select{|j| !j.success}
tell_about(discarded_jobs)
end
end I also tried to add an instance variable I'd greatly appreciate any help pointing me in the right direction for this. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
There isn't a public public api for job records, but it's simple enough to grab the Active Record models directly: jobs = GoodJob::Job.discarded.where(batch_id: batch.id) I wish that Active Job itself had a 1st party interface for presenting job status, but it does not. |
Beta Was this translation helpful? Give feedback.
There isn't a public public api for job records, but it's simple enough to grab the Active Record models directly:
I wish that Active Job itself had a 1st party interface for presenting job status, but it does not.