Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if a resque job with specific args is pending in queue

For example I enqueued a job as so

Resque.enqueue(MyJob, user.id)

Before en-queueing another job with the same user.id I would like to check if there already exists a job with that user id in the queue.

I hope there is some syntax like:

Resque.queue('MyQueue').has_pending_job(MyJob, user.id)
like image 816
david_adler Avatar asked Sep 27 '22 19:09

david_adler


1 Answers

I don't think there's such thing, you can achieve the same with multiple options

  1. You can have the has_pending_jobs attribute in the user, update it to true when the job starts and false when it ends

  2. use the resque-status extension https://github.com/quirkey/resque-status to keep track of the job_ids that are en queued for a certain user

  3. use separate queue for each user (this isn't scalable) and check if there's something in the queue for the user or not

like image 144
bigsolom Avatar answered Oct 02 '22 14:10

bigsolom