sidekiq-status 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d3dd7cc94267c99010ecd9b47129528e1c2a2a12
4
- data.tar.gz: b2fdf88b3ff5717fa202d92652d2b9bae0c40140
3
+ metadata.gz: b6b4364f29e4cebdacba46d6266532b800cd0626
4
+ data.tar.gz: cca02102cb3f156fc54ae6bfd7c737e6bbad9d46
5
5
  SHA512:
6
- metadata.gz: 6edd2298f96a0bcbcd3c7dc58426c328f159fd6de092e1764e31cfad2b07c00ba48dc4f7cdadd6e1d0b40c4e9b3c19ffb8f7af2dc33e9378f6e214a306822490
7
- data.tar.gz: f4ed9c45848b094916256730db4f286733e662d3a81735490fe1285d40fea464c9d787c72fad8f17c01ad67b8081eac93ebbd28c717a7939a7479939e7338f9b
6
+ metadata.gz: 4e124dcb4344613124d2d3b8d58f666e7c1bf9a1c41da241db09bce9823de03486bb6e4c916fc4c5f9dbcd3bc73278715092f7709d5cc18d1f7c82b618607bbf
7
+ data.tar.gz: e30d1f12e9388db15a59791aabb09e7adba4a461441c24b3a73bf34d4262c4cfb76edf850488bb66ba58800a7bec173b6233dba15412351ea67af8b2996d4ebe
@@ -1,2 +1,15 @@
1
1
  language: ruby
2
+ rvm:
3
+ - 2.0
4
+ - 2.1
5
+ - 2.2
6
+ - jruby
7
+ - rbx-2
8
+ gemfile:
9
+ - gemfiles/Gemfile.sidekiq-2
10
+ - Gemfile
2
11
  services: redis
12
+ matrix:
13
+ allow_failures:
14
+ - rvm: jruby
15
+ - rvm: rbx-2
data/CHANGELOG CHANGED
@@ -1,3 +1,4 @@
1
+ Version 0.5.2:Sidekiq versions up to 3.3.* supported, jobs sorting options in web UI, more ruby versions
1
2
  Version 0.5.1:dependencies versions requirements relaxed
2
3
  Version 0.5.0:Sidekiq v3 support, redis pools support
3
4
  Version 0.4.0:WebUI added, per-worker expiration setting enabled
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec path: '..'
4
+
5
+ gem 'sidekiq', '~> 2.17'
@@ -1,5 +1,5 @@
1
1
  module Sidekiq
2
2
  module Status
3
- VERSION = "0.5.1"
3
+ VERSION = "0.5.2"
4
4
  end
5
5
  end
@@ -19,7 +19,13 @@ module Sidekiq::Status
19
19
  queue = Sidekiq::Workers.new
20
20
  @statuses = []
21
21
 
22
- queue.each do |process, name, work, started_at|
22
+ queue.each do |*args|
23
+ work = if args[1].is_a?(Hash)
24
+ # For sidekiq < 3
25
+ args[1]
26
+ else
27
+ args[2]
28
+ end
23
29
  job = Struct.new(:jid, :klass, :args).new(work["payload"]["jid"], work["payload"]["class"], work["payload"]["args"])
24
30
  status = Sidekiq::Status::get_all job.jid
25
31
  next if !status || status.count < 2
@@ -30,6 +36,36 @@ module Sidekiq::Status
30
36
  @statuses << OpenStruct.new(status)
31
37
  end
32
38
 
39
+ if ["worker", "status", "update_time", "pct_complete", "message"].include?(params[:sort_by])
40
+ sort_by = params[:sort_by]
41
+ else
42
+ sort_by = "worker"
43
+ end
44
+
45
+ sort_dir = "asc"
46
+
47
+ if params[:sort_dir] == "asc"
48
+ @statuses = @statuses.sort { |x,y| x.send(sort_by) <=> y.send(sort_by) }
49
+ else # DESC
50
+ sort_dir = "desc"
51
+ @statuses = @statuses.sort { |y,x| x.send(sort_by) <=> y.send(sort_by) }
52
+ end
53
+
54
+ @headers = [
55
+ { id: "worker", name: "Worker/jid", class: nil, url: nil},
56
+ { id: "status", name: "Status", class: nil, url: nil},
57
+ { id: "update_time", name: "Last Updated", class: nil, url: nil},
58
+ { id: "pct_complete", name: "Progress", class: nil, url: nil},
59
+ { id: "message", name: "Message", class: nil, url: nil}
60
+ ]
61
+
62
+ @headers.each do |h|
63
+ params["sort_by"] = h[:id]
64
+ params["sort_dir"] = (sort_by == h[:id] && sort_dir == "asc") ? "desc" : "asc"
65
+ h[:url] = "statuses?" + params.map {|k,v| "#{k}=#{v}" }.join("&")
66
+ h[:class] = "sorted_#{sort_dir}" if sort_by == h[:id]
67
+ end
68
+
33
69
  erb(sidekiq_status_template(:statuses))
34
70
  end
35
71
  end
@@ -15,6 +15,8 @@ Gem::Specification.new do |gem|
15
15
  gem.version = Sidekiq::Status::VERSION
16
16
 
17
17
  gem.add_dependency 'sidekiq', '>= 2.7', '< 3.4'
18
+ gem.add_development_dependency 'rack-test'
18
19
  gem.add_development_dependency 'rake'
19
20
  gem.add_development_dependency 'rspec'
21
+ gem.add_development_dependency 'sinatra'
20
22
  end
@@ -0,0 +1,34 @@
1
+ require 'spec_helper'
2
+ require 'sidekiq-status/web'
3
+ require 'rack/test'
4
+
5
+ describe 'sidekiq status web' do
6
+ include Rack::Test::Methods
7
+
8
+ let!(:redis) { Sidekiq.redis { |conn| conn } }
9
+ let!(:job_id) { SecureRandom.hex(12) }
10
+
11
+ # Clean Redis before each test
12
+ # Seems like flushall has no effect on recently published messages,
13
+ # so we should wait till they expire
14
+ before { redis.flushall; sleep 0.1 }
15
+
16
+ def app
17
+ Sidekiq::Web
18
+ end
19
+
20
+ it 'shows a job in progress' do
21
+ allow(SecureRandom).to receive(:hex).once.and_return(job_id)
22
+
23
+ start_server do
24
+ capture_status_updates(2) do
25
+ expect(LongJob.perform_async(1)).to eq(job_id)
26
+ end
27
+
28
+ get '/statuses'
29
+ expect(last_response.status).to eq(200)
30
+ expect(last_response.body).to match(/#{job_id}/)
31
+ end
32
+ end
33
+
34
+ end
@@ -1,13 +1,18 @@
1
- <h3 class="wi">Recent job statuses</h3>
2
-
1
+ <style>
2
+ .sorted_asc:after{
3
+ content: " ↑";
4
+ }
5
+ .sorted_desc:after{
6
+ content: " ↓";
7
+ }
8
+ </style>
3
9
 
10
+ <h3 class="wi">Recent job statuses</h3>
4
11
  <table class="table table-striped table-bordered">
5
12
  <tr>
6
- <th>Worker/jid</th>
7
- <th>Status</th>
8
- <th>Last Updated ↆ</th>
9
- <th>Progress</th>
10
- <th>Message</th>
13
+ <% @headers.each do |header| %>
14
+ <th><a href="<%= header[:url] %>" class="<%= header[:class] %>"><%= header[:name] %></a></th>
15
+ <% end %>
11
16
  </tr>
12
17
  <% @statuses.each do |container| %>
13
18
  <tr>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-status
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evgeniy Tsvigun
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-27 00:00:00.000000000 Z
11
+ date: 2015-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sidekiq
@@ -30,6 +30,20 @@ dependencies:
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '3.4'
33
+ - !ruby/object:Gem::Dependency
34
+ name: rack-test
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
33
47
  - !ruby/object:Gem::Dependency
34
48
  name: rake
35
49
  requirement: !ruby/object:Gem::Requirement
@@ -58,6 +72,20 @@ dependencies:
58
72
  - - ">="
59
73
  - !ruby/object:Gem::Version
60
74
  version: '0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: sinatra
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
61
89
  description:
62
90
  email:
63
91
  - utgarda@gmail.com
@@ -73,6 +101,7 @@ files:
73
101
  - LICENSE
74
102
  - README.md
75
103
  - Rakefile
104
+ - gemfiles/Gemfile.sidekiq-2
76
105
  - lib/sidekiq-status.rb
77
106
  - lib/sidekiq-status/client_middleware.rb
78
107
  - lib/sidekiq-status/server_middleware.rb
@@ -85,6 +114,7 @@ files:
85
114
  - spec/lib/sidekiq-status/client_middleware_spec.rb
86
115
  - spec/lib/sidekiq-status/server_middleware_spec.rb
87
116
  - spec/lib/sidekiq-status/testing_spec.rb
117
+ - spec/lib/sidekiq-status/web_spec.rb
88
118
  - spec/lib/sidekiq-status/worker_spec.rb
89
119
  - spec/lib/sidekiq-status_spec.rb
90
120
  - spec/spec_helper.rb
@@ -110,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
140
  version: '0'
111
141
  requirements: []
112
142
  rubyforge_project:
113
- rubygems_version: 2.2.2
143
+ rubygems_version: 2.4.5
114
144
  signing_key:
115
145
  specification_version: 4
116
146
  summary: An extension to the sidekiq message processing to track your jobs
@@ -118,6 +148,7 @@ test_files:
118
148
  - spec/lib/sidekiq-status/client_middleware_spec.rb
119
149
  - spec/lib/sidekiq-status/server_middleware_spec.rb
120
150
  - spec/lib/sidekiq-status/testing_spec.rb
151
+ - spec/lib/sidekiq-status/web_spec.rb
121
152
  - spec/lib/sidekiq-status/worker_spec.rb
122
153
  - spec/lib/sidekiq-status_spec.rb
123
154
  - spec/spec_helper.rb