delayed_job_web 1.2.10 → 1.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of delayed_job_web might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dbcba0ad96175e81e6fae7a52cf978605d65e2c6
4
- data.tar.gz: f3065d7b9dea29396b9f9727c4391e464f4b2737
3
+ metadata.gz: 45e241e7f0f782f3ca6752c987f59544ac8aad17
4
+ data.tar.gz: 1ad7f26ed45b038275afa3f8a81c7c6dc795cb01
5
5
  SHA512:
6
- metadata.gz: 9dfeb2edec1976930a999cc798de7d00facfce2bb024d10c7e32877f83553ec50fb3c8fbb7b0404e4111f1b3e7a29d722517d33251c15d578c61a30aaea9cdd3
7
- data.tar.gz: dea580745305488adb0c1dbf9661392f1fbbc00cb0031b0e4c1958db21a713b86418a48ce338aff2b1636bc0302ee9bd95cf7fc5bafb260f36dc6999acde7a28
6
+ metadata.gz: 899e50f7f1850645db6bb567ec0a4140ec9f3ef23f51426a233a95d5adf5584291d13a0b307ba6dcf2ef1a364bbe639b7fc543c0351db36e01093022fcf7b852
7
+ data.tar.gz: 913d403293ad90b84b97f29510eccf270419a849790496f4beab10aa47388a1117a8118f0d43fd5d36dae20c2c65604b89cbb050a6d71cb58ec80b43ccf46598
data/README.markdown CHANGED
@@ -7,15 +7,16 @@ activerecord.
7
7
 
8
8
  Some features:
9
9
 
10
- * Easily view jobs enqueued, working, pending, and failed.
11
- * Queue any single job. or all pending jobs, to run immediately.
12
- * Remove a failed job, or easily remove all failed jobs.
10
+ * Easily view enqueued, working, pending, and failed jobs.
11
+ * Queue any single job or all pending jobs to run immediately.
12
+ * Remove a failed job or easily remove all failed jobs.
13
13
  * Watch delayed_job operation with live ajax polling.
14
- * Filter delayed_jobs by queue name
14
+ * Filter delayed_jobs by queue names (comma separated values in the input filter).
15
+ * Reset all queue filters by clicking the reset button.
15
16
 
16
- The interface (yea, a ripoff of resque-web):
17
+ The interface (yeah, a ripoff of resque-web):
17
18
 
18
- ![Screen shot](http://dl.dropbox.com/u/1506097/Screenshots/delayed_job_web_1.png)
19
+ ![Screen shot](./delayed_job_web.png)
19
20
 
20
21
 
21
22
  Quick Start For Rails 3 and 4 Applications
@@ -37,7 +38,7 @@ Add the following route to your application for accessing the interface,
37
38
  and retrying failed jobs.
38
39
 
39
40
  ```ruby
40
- match "/delayed_job" => DelayedJobWeb, :anchor => false, via: [:get, :post]
41
+ match "/delayed_job" => DelayedJobWeb, :anchor => false, :via => [:get, :post]
41
42
  ```
42
43
 
43
44
  You probably want to password protect the interface, an easy way is to add something like this your config.ru file
@@ -45,13 +46,38 @@ You probably want to password protect the interface, an easy way is to add somet
45
46
  ```ruby
46
47
  if Rails.env.production?
47
48
  DelayedJobWeb.use Rack::Auth::Basic do |username, password|
48
- username == 'username' && password == 'password'
49
+ ActiveSupport::SecurityUtils.variable_size_secure_compare('username', username) &&
50
+ ActiveSupport::SecurityUtils.variable_size_secure_compare('password', password)
49
51
  end
50
52
  end
51
53
  ```
52
54
 
53
55
  `delayed_job_web` runs as a Sinatra application within the rails application. Visit it at `/delayed_job`.
54
56
 
57
+
58
+ ## Authenticating with Devise and Warden
59
+
60
+ This can be accomplished in the routes.rb file using an `authenticated` callback. Note, do not use an `authenticate` callback as this forces an authentication check and redirects can be screwy, [see here](http://excid3.com/blog/rails-tip-5-authenticated-root-and-dashboard-routes-with-devise/) for more information.
61
+
62
+ A simple user check looks like this:
63
+
64
+ ```ruby
65
+
66
+ authenticated :user do
67
+ mount DelayedJobWeb, at: "/delayed_job"
68
+ end
69
+
70
+ ```
71
+ But you probably want to check for administrator permissions:
72
+
73
+ ```ruby
74
+
75
+ authenticated :user, -> user { user.admin? } do
76
+ mount DelayedJobWeb, at: "/delayed_job"
77
+ end
78
+
79
+ ```
80
+
55
81
  ## Serving static assets
56
82
 
57
83
  If you mount the app on another route, you may encounter the CSS not working anymore. To work around this you can leverage a special HTTP header. Install it, activate it and configure it -- see below.
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = "delayed_job_web"
3
- gem.version = "1.2.10"
3
+ gem.version = "1.3"
4
4
  gem.author = "Erick Schmitt"
5
5
  gem.email = "ejschmitt@gmail.com"
6
6
  gem.homepage = "https://github.com/ejschmitt/delayed_job_web"
@@ -49,6 +49,20 @@ class DelayedJobWeb < Sinatra::Base
49
49
 
50
50
  alias_method :u, :url_path
51
51
 
52
+ def queue_path(queue)
53
+ with_queue(queue) do
54
+ url_path(:overview)
55
+ end
56
+ end
57
+
58
+ def with_queue(queue, &block)
59
+ aux_queues = @queues
60
+ @queues = Array(queue)
61
+ result = block.call
62
+ @queues = aux_queues
63
+ result
64
+ end
65
+
52
66
  def h(text)
53
67
  Rack::Utils.escape_html(text)
54
68
  end
@@ -77,17 +77,17 @@
77
77
  return daysfrom + " days from now";
78
78
  }
79
79
  } else if (delta < -(48*60*60)) {
80
- return '1 day from now';
80
+ return '2 days from now';
81
81
  } else if (delta < -(24*60*60)) {
82
+ return '1 day from now';
83
+ } else if (delta < -(120*60)) {
82
84
  return 'about ' + parseInt(Math.abs(delta / 3600)).toString() +
83
85
  ' hours from now';
84
- } else if (delta < -(120*60)) {
85
- return 'about an hour from now';
86
86
  } else if (delta < -(45*60)) {
87
+ return 'about an hour from now';
88
+ } else if (delta < -60) {
87
89
  return parseInt(Math.abs(delta / 60)).toString()
88
90
  + ' minutes from now';
89
- } else if (delta < -60) {
90
- return 'about a minute from now';
91
91
  } else if (delta < 0) {
92
92
  return 'less than a minute from now';
93
93
  } else if (delta < 60) {
@@ -102,7 +102,6 @@
102
102
  return 'about ' + (parseInt(delta / 3600)).toString() + ' hours ago';
103
103
  } else if (delta < (48*60*60)) {
104
104
  return '1 day ago';
105
- } else {
106
105
  var days = (parseInt(delta / 86400)).toString();
107
106
  if (days > 5) {
108
107
  var fmt = '%B %d, %Y'
@@ -21,6 +21,12 @@
21
21
  <input type="submit" value="Filter" />
22
22
  </form>
23
23
  </li>
24
+ <li>
25
+ <form method="get" class="header-queues" action="" style="display:inline;">
26
+ <input name="queues" type="hidden" value="" />
27
+ <input type="submit" value="Reset" />
28
+ </form>
29
+ </li>
24
30
  </ul>
25
31
  </div>
26
32
  <div id="main">
@@ -42,4 +42,25 @@
42
42
  </td>
43
43
  </tr>
44
44
  </table>
45
+
46
+ <table class="overview">
47
+ <tr>
48
+ <th>Queue</th>
49
+ <th>Count</th>
50
+ </tr>
51
+
52
+ <% delayed_jobs(nil).group(:queue).size.each do |queue, count| %>
53
+ <tr>
54
+ <td class="status">
55
+ <a href="<%= queue_path(queue) %>">
56
+ <%= queue %>
57
+ </a>
58
+ </td>
59
+ <td>
60
+ <%= count %>
61
+ </td>
62
+ </tr>
63
+ <% end %>
64
+ </table>
65
+
45
66
  <%= poll %>
@@ -35,7 +35,7 @@ class TestDelayedJobWeb < MiniTest::Unit::TestCase
35
35
 
36
36
  dataset = Minitest::Mock.new
37
37
  where = lambda { | criteria |
38
- criteria.must_equal 'last_error IS NOT NULL'
38
+ criteria.must_equal :attempts => 0, :locked_at => nil
39
39
  dataset
40
40
  }
41
41
 
@@ -43,7 +43,7 @@ class TestDelayedJobWeb < MiniTest::Unit::TestCase
43
43
 
44
44
  Time.stub(:now, time) do
45
45
  Delayed::Job.stub(:where, where) do
46
- post "/requeue/failed", request_data, rack_env
46
+ post "/requeue/pending", request_data, rack_env
47
47
  last_response.status.must_equal 302
48
48
  end
49
49
  end
@@ -14,6 +14,14 @@ class Delayed::Job
14
14
  def limit(*args)
15
15
  DelayedJobFake.new
16
16
  end
17
+
18
+ def size(*args)
19
+ {}
20
+ end
21
+ end
22
+
23
+ def self.group(*args)
24
+ DelayedJobFake.new
17
25
  end
18
26
 
19
27
  def self.where(*args)
@@ -31,4 +39,4 @@ class Delayed::Job
31
39
  def self.find(*args)
32
40
  DelayedJobFake.new
33
41
  end
34
- end
42
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: delayed_job_web
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.10
4
+ version: '1.3'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erick Schmitt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-28 00:00:00.000000000 Z
11
+ date: 2017-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra
@@ -153,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
153
  version: '0'
154
154
  requirements: []
155
155
  rubyforge_project:
156
- rubygems_version: 2.2.2
156
+ rubygems_version: 2.4.5.1
157
157
  signing_key:
158
158
  specification_version: 4
159
159
  summary: Web interface for delayed_job inspired by resque