In my application, I'm using Resque to resize images. If an image is in the resizing queue, I want to show a "resizing image" icon.
This means that I need to be able to find all current jobs relating to a specific model ID in the queue. Right now I do it like this:
Resque.peek(:resize, 0, 100).find_all { |job| /#{model.id}/.match(job["args"][0]) }
This is stupid. But is there any way to query the Resque queue to find all jobs where the first argument is equal to [id]?
Thanks in advance.
Give resque-status a try. It is an extension to Resque that adds job tracking.
resque-status provides a set of simple classes that extend resque’s default functionality (with 0% monkey patching) to give apps a way to track specific job instances and their status. It achieves this by giving job instances UUID’s and allowing the job instances to report their status from within their iterations.
Note: d11wtq mentioned this above as a comment, but is actually the best answer so far.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With