resque / resque-web

a Rails-based web interface to Resque
235 stars 166 forks source link

Cancel job doesn't work if queued in a different queue #152

Closed kapcod closed 4 years ago

kapcod commented 4 years ago

delayed_cancel_now calls Resque.remove_delayed_job_from_timestamp which expects the job to be queued in the queue that defined in the job class. But it's not always the case. In our codebase, we sometimes don't define queues at all and either defining the queue in resque_scheduler.yml or Resque.enqueue_at_with_queue.

I suggest passing "queue" as a parameter to /delayed/cancel_now and using job_to_hash_with_queue to encode the job.

This will also help it deal with constants that are not autoloaded and dependent on Rails lazy load.