resque-scheduler icon indicating copy to clipboard operation
resque-scheduler copied to clipboard

Resque#scheduled_at returning empty array

Open dlachasse opened this issue 10 years ago • 5 comments

I'm currently running Rails 4.2.0 and have a number of jobs tied to a specific class. When I call Resque.scheduled_at(class_name). I'm getting an empty array returned. I know the jobs exist because when I'm calling just Resque.schedule I get the hash listing all of my jobs out. I'd provide a stack trace but I'm not getting any errors! Is this broken for anyone else on Rails 4.2.0?

dlachasse avatar Jun 05 '15 17:06 dlachasse

The trouble here is that in order to search, we need the whole payload of the job, not just its class.

https://github.com/resque/resque-scheduler/blob/v4.0.0/lib/resque/scheduler/delaying_extensions.rb#L218-L224

yaauie avatar Jun 05 '15 17:06 yaauie

Thanks for the quick response @yaauie. So I've tried passing in the *args as well and I'm still getting the same response. Here's an example of the setup.

resque_schedule.yml

some_scheduled_job:
  cron: "0 2 * * *"
  class: "SomeJob"
  args: "SomeArg"
  description: "Do Something"


Resque.scheduled_at(SomeJob, ["SomeArg"]) => []

dlachasse avatar Jun 05 '15 18:06 dlachasse

The trouble is that the args have to be exact.

In this case, I believe it is different because Resque::scheduled_at takes a variable number of args, so the * (splat) may be causing some confusion, causing args to be [["SomeArg"]] (notice the extra layer of array).

I think you would mean:

Resque.scheduled_at(SomeJob, "SomeArg")

yaauie avatar Jun 05 '15 21:06 yaauie

@yaauie We've tried about every combination of args and even jobs not requiring any args at all and it fails to return anything. Any tips?

cgpsn avatar Jun 05 '15 21:06 cgpsn

Based on the source for Rescue.scheduled_at I checked redis for keys starting with timestamps: and came up short:

irb(main):003:0> REDIS.keys('timestamps:*')
=> []

Does this method eagerly store a job in redis for jobs in the schedule or does this only return jobs explicitly scheduled with Resque.enqueue_at?

greggroth avatar Jun 05 '15 22:06 greggroth