README.md in delayed_job_progress-0.0.1 vs README.md in delayed_job_progress-0.0.2

- old
+ new

@@ -1,9 +1,9 @@ # DelayedJobProgress [![Gem Version](https://img.shields.io/gem/v/delayed_job_progress.svg?style=flat)](http://rubygems.org/gems/delayed_job_progress) [![Gem Downloads](https://img.shields.io/gem/dt/delayed_job_progress.svg?style=flat)](http://rubygems.org/gems/delayed_job_progress) [![Build Status](https://img.shields.io/travis/GBH/delayed_job_progress.svg?style=flat)](https://travis-ci.org/GBH/delayed_job_progress) -Extension for `Delayed::Job` that allows better tracking of jobs! +Extension for [Delayed::Job](https://github.com/collectiveidea/delayed_job) that allows better tracking of jobs! ## Setup * add to Gemfile: `gem 'delayed_job_progress'` * `bundle install` @@ -15,11 +15,11 @@ Consider this: ```ruby class User < ActiveRecord::Base # convenient relationship to grab associated jobs - has_many :jobs, :as => :record, :class_name => 'DelayedJob' + has_many :jobs, :as => :record, :class_name => 'Delayed::Job' end ``` Creating a delayed job: ```ruby @@ -41,16 +41,16 @@ @job = job @user = job.record end def perform - @job.update_column(:progress_state, 'working') + @job.update_column(:message, 'working') (0..100).each do |i| @user.do_a_thing(i) @job.update_column(:progress_current, i) end - @job.update_column(:progress_state, 'complete') + @job.update_column(:message, 'complete') end end Delayed::Job.enqueue CustomUserJob.new(123) ``` @@ -66,22 +66,27 @@ -> Delayed::Job.last.record => #<User> ``` `Delayed::Job` records now have new attributes: -* `progress_max` - default is `100`. You can change it to whatever during `enqueue`. -* `progress_current` - default is `0`. You can manually increment it while job is running. Will be set to `process_max` when job completes. -* `progress_state` - default is `nil`. Optional informational string. -* `completed_at` - when job is done this timestamp is recorded. +``` +`progress_max` - default is `100`. You can change it to whatever during `enqueue`. +`progress_current` - default is `0`. You can manually increment it while job is running. Will be set to `process_max` when job completes. +`message` - default is `nil`. Optional informational string. +`error_message` - error message without backtrace. Also useful to set your own message. +`completed_at` - when job is done this timestamp is recorded. +`identifier` - you can assign something during `enqueue` so you can fetch that job later for display. +``` This extension also introduces worker setting that keeps completed jobs around. This way you can keep list of completed jobs for a while. If you want to remove them, you need to `.destroy(:force)` them. ``` Delayed::Worker.destroy_completed_jobs = false ``` ## Jobs Controller -- `GET /jobs` - List all jobs. Can filter based on associated record via `record_type` and `record_id` parameters. `identifier` parameter can be used as well -- `GET /jobs/<id>` - Status of a job. Will see all the Delayed::Job attributes including things like progress -- `DELETE /jobs/<id>` - If job is stuck/failed, we can remove it -- `POST /jobs/<id>/reload` - Restart failed job - +``` +GET /jobs - List all jobs. Can filter based on associated record via `record_type` and `record_id` parameters. `identifier` parameter can be used as well +GET /jobs/<id> - Status of a job. Will see all the Delayed::Job attributes including things like progress +DELETE /jobs/<id>` - If job is stuck/failed, we can remove it +POST /jobs/<id>/reload` - Restart failed job +```