delayed_job_progress 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/.travis.yml +3 -1
- data/README.md +28 -8
- data/Rakefile +1 -1
- data/delayed_job_progress.gemspec +1 -1
- data/lib/delayed_job_progress/version.rb +1 -1
- data/progress.gif +0 -0
- data/test/Gemfile.rails-5.0 +5 -0
- data/test/dummy/Rakefile +1 -1
- data/test/dummy/app/assets/config/manifest.js +5 -0
- data/test/dummy/app/assets/javascripts/application.js +1 -1
- data/test/dummy/app/assets/javascripts/cable.js +13 -0
- data/test/dummy/app/{mailers → assets/javascripts/channels}/.keep +0 -0
- data/test/dummy/app/assets/stylesheets/application.css +3 -3
- data/test/dummy/app/channels/application_cable/channel.rb +4 -0
- data/test/dummy/app/channels/application_cable/connection.rb +4 -0
- data/test/dummy/app/controllers/application_controller.rb +0 -2
- data/test/dummy/app/jobs/application_job.rb +2 -0
- data/test/dummy/app/mailers/application_mailer.rb +4 -0
- data/test/dummy/app/models/application_record.rb +3 -0
- data/test/dummy/app/views/layouts/application.html.erb +9 -9
- data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/test/dummy/bin/rails +1 -1
- data/test/dummy/bin/setup +21 -12
- data/test/dummy/bin/update +29 -0
- data/test/dummy/bin/yarn +11 -0
- data/test/dummy/config.ru +2 -1
- data/test/dummy/config/application.rb +4 -12
- data/test/dummy/config/boot.rb +2 -2
- data/test/dummy/config/cable.yml +10 -0
- data/test/dummy/config/database.yml +1 -1
- data/test/dummy/config/environment.rb +1 -1
- data/test/dummy/config/environments/development.rb +24 -11
- data/test/dummy/config/environments/production.rb +28 -16
- data/test/dummy/config/environments/test.rb +6 -6
- data/test/dummy/config/initializers/application_controller_renderer.rb +6 -0
- data/test/dummy/config/initializers/assets.rb +6 -3
- data/test/dummy/config/initializers/cookies_serializer.rb +2 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +2 -2
- data/test/dummy/config/locales/en.yml +10 -0
- data/test/dummy/config/puma.rb +56 -0
- data/test/dummy/config/routes.rb +0 -1
- data/test/dummy/config/secrets.yml +15 -5
- data/test/dummy/config/spring.rb +6 -0
- data/test/dummy/package.json +5 -0
- data/test/dummy/public/404.html +6 -6
- data/test/dummy/public/422.html +6 -6
- data/test/dummy/public/500.html +6 -6
- data/test/dummy/{app/models/.keep → public/apple-touch-icon-precomposed.png} +0 -0
- data/test/dummy/public/apple-touch-icon.png +0 -0
- data/test/extensions/job_test.rb +3 -3
- data/test/extensions/worker_test.rb +2 -2
- data/test/jobs_controller_test.rb +7 -7
- metadata +68 -44
- data/test/dummy/README.rdoc +0 -28
- data/test/dummy/config/initializers/session_store.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8957004157b1b044edaf822c9c07a9bad7882999
|
4
|
+
data.tar.gz: 0704dc3c006e8e3314aedee3eef8d649b23c5742
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ea429083df722cd60996770be94777992bb154627914366f8ab46f505f2b251f2e89358a4aa07a29a1a8e7e42f914d28fcbb377d328a0aaaa5e92ba57fa8cef
|
7
|
+
data.tar.gz: a7003f3000a650c5dd4d8cd0062e578e86ddf0103db9db3315496158d47bf6bc191c08a55a31c6e9b8369be1cf40a2ef4533147a556b0f450d9c326c11e8cf73
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
# DelayedJobProgress
|
2
2
|
[![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)
|
3
3
|
|
4
|
-
Extension for [Delayed::Job](https://github.com/collectiveidea/delayed_job) that allows better tracking of jobs!
|
4
|
+
Extension for [Delayed::Job](https://github.com/collectiveidea/delayed_job) that allows for better tracking of jobs!
|
5
|
+
|
6
|
+
![progress](https://raw.githubusercontent.com/GBH/delayed_job_progress/master/progress.gif)
|
5
7
|
|
6
8
|
## Setup
|
7
9
|
|
@@ -69,12 +71,14 @@ That job knows about object that spawned it:
|
|
69
71
|
|
70
72
|
`Delayed::Job` records now have new attributes:
|
71
73
|
```
|
72
|
-
`progress_max` -
|
73
|
-
`progress_current` -
|
74
|
-
|
75
|
-
`
|
76
|
-
`
|
77
|
-
`
|
74
|
+
`progress_max` - Default is `100`. You can change it to whatever during `enqueue`.
|
75
|
+
`progress_current` - Default is `0`. You can manually increment it while job is running.
|
76
|
+
Will be set to `process_max` when job completes.
|
77
|
+
`message` - Default is `nil`. Optional informational string.
|
78
|
+
`error_message` - Error message without backtrace. Also useful to set your own message.
|
79
|
+
`completed_at` - When job is done this timestamp is recorded.
|
80
|
+
`identifier` - You can assign something during `enqueue` so you can fetch that job later for display.
|
81
|
+
`status` - Virtual read-only attribute. Can be `queued`, `processing`, `completed` or `failed`
|
78
82
|
```
|
79
83
|
|
80
84
|
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.
|
@@ -84,9 +88,25 @@ Delayed::Worker.destroy_completed_jobs = false
|
|
84
88
|
|
85
89
|
## Jobs Controller
|
86
90
|
|
91
|
+
You may mount jobs controller in your routes by adding:
|
92
|
+
|
93
|
+
```ruby
|
94
|
+
mount DelayedJobProgress::Engine => '/delayed'
|
87
95
|
```
|
88
|
-
|
96
|
+
|
97
|
+
Following JSON serving end-points will become available:
|
98
|
+
|
99
|
+
```
|
100
|
+
GET /jobs - List all jobs. Can filter based on associated record via `record_type` and `record_id`
|
101
|
+
parameters. `identifier` parameter can be used as well
|
89
102
|
GET /jobs/<id> - Status of a job. Will see all the Delayed::Job attributes including things like progress
|
90
103
|
DELETE /jobs/<id>` - If job is stuck/failed, we can remove it
|
91
104
|
POST /jobs/<id>/reload` - Restart failed job
|
92
105
|
```
|
106
|
+
|
107
|
+
## Front-end
|
108
|
+
This gem doesn't have a front-end component to show fancy progress bar. Common way to accomplish that would be to create a javascript poller that would periodically hit `/jobs/<id>` enpoint and update progress bar with progress data + messages.
|
109
|
+
|
110
|
+
---
|
111
|
+
|
112
|
+
Copyright 2016 Oleg Khabarov
|
data/Rakefile
CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.files = `git ls-files`.split("\n")
|
18
18
|
s.test_files = Dir["test/**/*"]
|
19
19
|
|
20
|
-
s.add_dependency 'rails', '>= 4.0.0'
|
20
|
+
s.add_dependency 'rails', '>= 4.0.0'
|
21
21
|
s.add_dependency 'delayed_job', '>= 4.0'
|
22
22
|
s.add_dependency 'delayed_job_active_record', '>= 4.0'
|
23
23
|
|
data/progress.gif
ADDED
Binary file
|
data/test/dummy/Rakefile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
2
2
|
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
3
3
|
|
4
|
-
|
4
|
+
require_relative 'config/application'
|
5
5
|
|
6
6
|
Rails.application.load_tasks
|
@@ -5,7 +5,7 @@
|
|
5
5
|
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
6
|
//
|
7
7
|
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
-
// compiled file.
|
8
|
+
// compiled file. JavaScript code in this file should be added after the last require_* statement.
|
9
9
|
//
|
10
10
|
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
11
|
// about supported directives.
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// Action Cable provides the framework to deal with WebSockets in Rails.
|
2
|
+
// You can generate new channels where WebSocket features live using the `rails generate channel` command.
|
3
|
+
//
|
4
|
+
//= require action_cable
|
5
|
+
//= require_self
|
6
|
+
//= require_tree ./channels
|
7
|
+
|
8
|
+
(function() {
|
9
|
+
this.App || (this.App = {});
|
10
|
+
|
11
|
+
App.cable = ActionCable.createConsumer();
|
12
|
+
|
13
|
+
}).call(this);
|
File without changes
|
@@ -6,9 +6,9 @@
|
|
6
6
|
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
7
|
*
|
8
8
|
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
-
* compiled file so the styles you add here take precedence over styles defined in any
|
10
|
-
*
|
11
|
-
* file per style scope.
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
11
|
+
* It is generally better to create a new file per style scope.
|
12
12
|
*
|
13
13
|
*= require_tree .
|
14
14
|
*= require_self
|
@@ -1,14 +1,14 @@
|
|
1
1
|
<!DOCTYPE html>
|
2
2
|
<html>
|
3
|
-
<head>
|
4
|
-
|
5
|
-
|
6
|
-
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
|
7
|
-
<%= csrf_meta_tags %>
|
8
|
-
</head>
|
9
|
-
<body>
|
3
|
+
<head>
|
4
|
+
<title>Dummy</title>
|
5
|
+
<%= csrf_meta_tags %>
|
10
6
|
|
11
|
-
<%=
|
7
|
+
<%= stylesheet_link_tag 'application', media: 'all' %>
|
8
|
+
<%= javascript_include_tag 'application' %>
|
9
|
+
</head>
|
12
10
|
|
13
|
-
|
11
|
+
<body>
|
12
|
+
<%= yield %>
|
13
|
+
</body>
|
14
14
|
</html>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= yield %>
|
data/test/dummy/bin/rails
CHANGED
data/test/dummy/bin/setup
CHANGED
@@ -1,29 +1,38 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'pathname'
|
3
|
+
require 'fileutils'
|
4
|
+
include FileUtils
|
3
5
|
|
4
6
|
# path to your application root.
|
5
|
-
APP_ROOT = Pathname.new File.expand_path('../../',
|
7
|
+
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
|
6
8
|
|
7
|
-
|
9
|
+
def system!(*args)
|
10
|
+
system(*args) || abort("\n== Command #{args} failed ==")
|
11
|
+
end
|
12
|
+
|
13
|
+
chdir APP_ROOT do
|
8
14
|
# This script is a starting point to setup your application.
|
9
|
-
# Add necessary setup steps to this file
|
15
|
+
# Add necessary setup steps to this file.
|
16
|
+
|
17
|
+
puts '== Installing dependencies =='
|
18
|
+
system! 'gem install bundler --conservative'
|
19
|
+
system('bundle check') || system!('bundle install')
|
20
|
+
|
21
|
+
# Install JavaScript dependencies if using Yarn
|
22
|
+
# system('bin/yarn')
|
10
23
|
|
11
|
-
puts "== Installing dependencies =="
|
12
|
-
system "gem install bundler --conservative"
|
13
|
-
system "bundle check || bundle install"
|
14
24
|
|
15
25
|
# puts "\n== Copying sample files =="
|
16
|
-
# unless File.exist?(
|
17
|
-
#
|
26
|
+
# unless File.exist?('config/database.yml')
|
27
|
+
# cp 'config/database.yml.sample', 'config/database.yml'
|
18
28
|
# end
|
19
29
|
|
20
30
|
puts "\n== Preparing database =="
|
21
|
-
system
|
31
|
+
system! 'bin/rails db:setup'
|
22
32
|
|
23
33
|
puts "\n== Removing old logs and tempfiles =="
|
24
|
-
system
|
25
|
-
system "rm -rf tmp/cache"
|
34
|
+
system! 'bin/rails log:clear tmp:clear'
|
26
35
|
|
27
36
|
puts "\n== Restarting application server =="
|
28
|
-
system
|
37
|
+
system! 'bin/rails restart'
|
29
38
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'pathname'
|
3
|
+
require 'fileutils'
|
4
|
+
include FileUtils
|
5
|
+
|
6
|
+
# path to your application root.
|
7
|
+
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
|
8
|
+
|
9
|
+
def system!(*args)
|
10
|
+
system(*args) || abort("\n== Command #{args} failed ==")
|
11
|
+
end
|
12
|
+
|
13
|
+
chdir APP_ROOT do
|
14
|
+
# This script is a way to update your development environment automatically.
|
15
|
+
# Add necessary update steps to this file.
|
16
|
+
|
17
|
+
puts '== Installing dependencies =='
|
18
|
+
system! 'gem install bundler --conservative'
|
19
|
+
system('bundle check') || system!('bundle install')
|
20
|
+
|
21
|
+
puts "\n== Updating database =="
|
22
|
+
system! 'bin/rails db:migrate'
|
23
|
+
|
24
|
+
puts "\n== Removing old logs and tempfiles =="
|
25
|
+
system! 'bin/rails log:clear tmp:clear'
|
26
|
+
|
27
|
+
puts "\n== Restarting application server =="
|
28
|
+
system! 'bin/rails restart'
|
29
|
+
end
|
data/test/dummy/bin/yarn
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
VENDOR_PATH = File.expand_path('..', __dir__)
|
3
|
+
Dir.chdir(VENDOR_PATH) do
|
4
|
+
begin
|
5
|
+
exec "yarnpkg #{ARGV.join(" ")}"
|
6
|
+
rescue Errno::ENOENT
|
7
|
+
$stderr.puts "Yarn executable was not detected in the system."
|
8
|
+
$stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
|
9
|
+
exit 1
|
10
|
+
end
|
11
|
+
end
|
data/test/dummy/config.ru
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require_relative 'boot'
|
2
2
|
|
3
3
|
require 'rails/all'
|
4
4
|
|
@@ -7,20 +7,12 @@ require "delayed_job_progress"
|
|
7
7
|
|
8
8
|
module Dummy
|
9
9
|
class Application < Rails::Application
|
10
|
+
# Initialize configuration defaults for originally generated Rails version.
|
11
|
+
# config.load_defaults 5.1
|
12
|
+
|
10
13
|
# Settings in config/environments/* take precedence over those specified here.
|
11
14
|
# Application configuration should go into files in config/initializers
|
12
15
|
# -- all .rb files in that directory are automatically loaded.
|
13
|
-
|
14
|
-
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
15
|
-
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
16
|
-
# config.time_zone = 'Central Time (US & Canada)'
|
17
|
-
|
18
|
-
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
19
|
-
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
20
|
-
# config.i18n.default_locale = :de
|
21
|
-
|
22
|
-
# Do not swallow errors in after_commit/after_rollback callbacks.
|
23
|
-
config.active_record.raise_in_transactional_callbacks = true
|
24
16
|
end
|
25
17
|
end
|
26
18
|
|
data/test/dummy/config/boot.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Set up gems listed in the Gemfile.
|
2
|
-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('
|
2
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__)
|
3
3
|
|
4
4
|
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
|
5
|
-
$LOAD_PATH.unshift File.expand_path('
|
5
|
+
$LOAD_PATH.unshift File.expand_path('../../../lib', __dir__)
|
@@ -9,13 +9,28 @@ Rails.application.configure do
|
|
9
9
|
# Do not eager load code on boot.
|
10
10
|
config.eager_load = false
|
11
11
|
|
12
|
-
# Show full error reports
|
13
|
-
config.consider_all_requests_local
|
14
|
-
|
12
|
+
# Show full error reports.
|
13
|
+
config.consider_all_requests_local = true
|
14
|
+
|
15
|
+
# Enable/disable caching. By default caching is disabled.
|
16
|
+
if Rails.root.join('tmp/caching-dev.txt').exist?
|
17
|
+
config.action_controller.perform_caching = true
|
18
|
+
|
19
|
+
config.cache_store = :memory_store
|
20
|
+
config.public_file_server.headers = {
|
21
|
+
'Cache-Control' => "public, max-age=#{2.days.seconds.to_i}"
|
22
|
+
}
|
23
|
+
else
|
24
|
+
config.action_controller.perform_caching = false
|
25
|
+
|
26
|
+
config.cache_store = :null_store
|
27
|
+
end
|
15
28
|
|
16
29
|
# Don't care if the mailer can't send.
|
17
30
|
config.action_mailer.raise_delivery_errors = false
|
18
31
|
|
32
|
+
config.action_mailer.perform_caching = false
|
33
|
+
|
19
34
|
# Print deprecation notices to the Rails logger.
|
20
35
|
config.active_support.deprecation = :log
|
21
36
|
|
@@ -27,15 +42,13 @@ Rails.application.configure do
|
|
27
42
|
# number of complex assets.
|
28
43
|
config.assets.debug = true
|
29
44
|
|
30
|
-
#
|
31
|
-
|
32
|
-
config.assets.digest = true
|
33
|
-
|
34
|
-
# Adds additional error checking when serving assets at runtime.
|
35
|
-
# Checks for improperly declared sprockets dependencies.
|
36
|
-
# Raises helpful error messages.
|
37
|
-
config.assets.raise_runtime_errors = true
|
45
|
+
# Suppress logger output for asset requests.
|
46
|
+
config.assets.quiet = true
|
38
47
|
|
39
48
|
# Raises error for missing translations
|
40
49
|
# config.action_view.raise_on_missing_translations = true
|
50
|
+
|
51
|
+
# Use an evented file watcher to asynchronously detect changes in source code,
|
52
|
+
# routes, locales, etc. This feature depends on the listen gem.
|
53
|
+
# config.file_watcher = ActiveSupport::EventedFileUpdateChecker
|
41
54
|
end
|