jrgifford/delayed_paperclip

Get Sidekiq job ID

Closed this issue · 4 comments

Hello,
Is there a way to somehow get sidekiq job id which corresponds to worker job responsible for image uploads?

This is a bit messy but, from Sidekiq you can query the queue with Sidekiq::Queue.new("paperclip").

Then the args for each job are an array, the first argument being a hash containing the class, job id, and the AJ arguments. So, you could query it something like this.

paperclip_queue = Sidekiq::Queue.new("paperclip")

# if i am search for a job for Asset model with id 451 and the paperclip attachment field of attachment
paperclip_queue.find { |job| job.args.first["arguments"] == ["Asset", 451, "attachment"] }

There is no public API in delayed_paperclip to do this.
As in future delayed_paperclip will only support active job, you can take a look if it's possible there.

@morgoth whoa, why active job only?

To try better maintain this gem. AJ takes care of all adapter differences and provides common interface that is widely used since Rails 4.2.
You can track it on #179