Progress Bar for Background Process in Rails

2019-04-23 13:26发布

问题:

I have a couple of processes in my Rails application that call to an external web API - and take a long time to finish. I've considered moving them to process in the background.

I would like to be able to show the user the progress of the background process (i.e. a progress bar).

First, are there any good tutorials/learning resources on implementing a progress bar with jQuery in Rails (not related to a file upload process)? I've seen a lot of resources on displaying the graphic - but not a lot of information on how to hook the graphic updating to the actual background process.

Second, as I consider the various gems for background processing, is there one that would work better with a progress bar (i.e. Delayed Jobs, Resque, Sidekiq)?

Thank you

回答1:

I just wrote a blog post about using Sidekiq + SidekiqStatus + Bootstrap theme progress bar = to implement a progress bar. I know it's been a while since this has been asked but hopefully, others will find it useful:

How to Implement a Progress Bar Using Sidekiq Status




回答2:

The gem Progress Job looks promising for providing progress updates on background jobs. At this time it looks like it works with DelayedJob.



回答3:

Use the startAjax event to trigger a function that hide/shows the progress bar.

I just answered this question in another post.

The url for the jqueryui progress meter docs is http://jqueryui.com/progressbar/