Reputation: 637
I have a ruby on rails app using the resque
gem to process background jobs. I have users trigger background jobs that can take upwards of 10 minutes to complete (they're processing a ton of data). What is the best way to alert the user when the job has completed?
I've seen the answer here about using resque-status
, is that the only solution? Or is there another way to alert the user through normal resque
(which I've already implemented)?
Upvotes: 1
Views: 2199
Reputation: 3339
You can use a gem called "resque-status".
Using this gem you can easily get a job's status:
status = Resque::Plugins::Status::Hash.get(job_id)
This Resque::Plugins::Status::Hash
object returns:
status.pct_complete #=> 0
status.status #=> 'queued'
status.queued? #=> true
status.working? #=> false
status.time #=> Time object
status.message #=> "Created at ..."
For more details and getting this gem visit: https://github.com/quirkey/resque-status
Upvotes: 3
Reputation: 16074
If you intend to notify a user asynchronously, you have three options:
Those are pretty much the only things I can think of. I would personally go with a combination of 1 and 2; send them an email on completion, and notify them (and provide a link in the notification) the next time they log in.
Upvotes: 4