Search code examples
ruby-on-railsresque

How to check if resque job has finished


I have a case scenario where I need to run multiple record updates in the background(using resque) and I want to give user visual indicator of how the task is running(eg started/running/finished).

One way of achieving this(which I can think of) is saving the current state into a table, then showing the state to user by simple page refresh.

Can anyone suggest a better solution of doing it?I want to avoid creating the whole migration, model, controller for this.

Thanks


Solution

  • As I've commented, resque-status gem could be useful for you. I am not sure if that is an answer but since you said that you do not want to create migration, model and controller for this. Thus, a gem might be the way to go.

    From the job id you can get the status you are looking for, for example:

    status = Resque::Plugins::Status::Hash.get(job_id)
    status.working? #=> true
    

    There is also a front-end called resque-web, check that out too.