sidekiq-status 1.1.1 → 2.0.1

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
  SHA256:
3
- metadata.gz: db6a8c9de958b260f3c12afef53ed33781ebbc227bbdf3b14792b41fb3ad2e20
4
- data.tar.gz: 9226346a24ff25fed5608d2fd75671c5f7ae4c637c44bbf096f9cd67464b4996
3
+ metadata.gz: 45893560f4594985006d2842f460861137e46903197e173761ad9bcd96db5b49
4
+ data.tar.gz: 5de9712752bf085f4792e4e018709e1fc9436a5f246c3c39ad4b0916df3f8df3
5
5
  SHA512:
6
- metadata.gz: fc3a3e5537f38c180df517dcb69674fa8cef9b1938b57324db8e26b41bcaf9b3c0ef0857f5b9ebbb6ee54106440e33203d2f1d8f4f5ccea4e205ae9d71b67c6f
7
- data.tar.gz: c1223771b2b7d8101d7f9ae3ef602c81cb1e408d66b6411023a2f37c7b9022d2f21dbb93addb12a8327847cb2e327df5c883f909ada59d85abdfe2f333619ba5
6
+ metadata.gz: ee2aa4d21c57403eb01b7fe5a011301dc2a085ffd8aa7498252684f7456d480a82642381c3a9cab970c9fbe9f3275db585de492a0574a474de8604c555f63853
7
+ data.tar.gz: 0bef9d092bf1c756195fcb46828ca3b85754cb597878d7d52164afb70f492a01416d45672d3de9cad7c7256afb366e1b736f7709ab1ebc5d34d85dc64f5756ff
data/.gitignore CHANGED
@@ -4,6 +4,7 @@ gemfiles/*.lock
4
4
  .bundle
5
5
  .config
6
6
  .rvmrc
7
+ .ruby-version
7
8
  .yardoc
8
9
  Gemfile.lock
9
10
  InstalledFiles
data/.gitlab-ci.yml ADDED
@@ -0,0 +1,17 @@
1
+ dependency_scanning:
2
+ image: docker:stable
3
+ variables:
4
+ DOCKER_DRIVER: overlay2
5
+ allow_failure: true
6
+ services:
7
+ - docker:stable-dind
8
+ script:
9
+ - export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
10
+ - docker run
11
+ --env DEP_SCAN_DISABLE_REMOTE_CHECKS="${DEP_SCAN_DISABLE_REMOTE_CHECKS:-false}"
12
+ --volume "$PWD:/code"
13
+ --volume /var/run/docker.sock:/var/run/docker.sock
14
+ "registry.gitlab.com/gitlab-org/security-products/dependency-scanning:$SP_VERSION" /code
15
+ artifacts:
16
+ reports:
17
+ dependency_scanning: gl-dependency-scanning-report.json
data/.travis.yml CHANGED
@@ -1,16 +1,19 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2
4
- - 2.3
5
- - 2.4
6
- - 2.5
3
+ - 2.6
4
+ - 2.7
5
+ - 3.0
6
+ - ruby-head
7
7
  gemfile:
8
- - gemfiles/sidekiq_3.x.gemfile
9
- - gemfiles/sidekiq_4.x.gemfile
10
8
  - gemfiles/sidekiq_5.x.gemfile
9
+ - gemfiles/sidekiq_6.x.gemfile
11
10
  before_install:
12
11
  - gem update --system
13
12
  - gem update bundler
14
13
  services: redis
15
14
  notifications:
16
15
  email: false
16
+ matrix:
17
+ fast_finish: true
18
+ allow_failures:
19
+ - rvm: ruby-head
data/Appraisals CHANGED
@@ -1,11 +1,7 @@
1
- appraise "sidekiq-3.x" do
2
- gem "sidekiq", "~> 3"
3
- end
4
-
5
- appraise "sidekiq-4.x" do
6
- gem "sidekiq", "~> 4"
7
- end
8
-
9
1
  appraise "sidekiq-5.x" do
10
2
  gem "sidekiq", "~> 5"
11
3
  end
4
+
5
+ appraise "sidekiq-6.x" do
6
+ gem "sidekiq", "~> 6"
7
+ end
data/CHANGELOG.md CHANGED
@@ -1,62 +1,12 @@
1
- **Version 1.1.1**
2
- * Uses SCAN rather than KEYS when retrieving job ids from Redis (#139)
1
+ **Version 2.0.1**
2
+ * Adds support for dark mode to the job status page
3
3
 
4
- **Version 1.1.0**
5
- + Fixes the use case of multiple services sharing the same Redis instance (#135)
4
+ **Version 2.0.0**
5
+ * Adds support for Ruby 2.7, 3.0
6
+ * Adds support for Sidekiq 6.x
7
+ * Removes support for Ruby 2.3, 2.4, 2.5
8
+ * Removes support for Sidekiq 3.x, 4.x
6
9
 
7
- **Version 1.0.2**
8
- + Fixes status not being set to `:failed` after retries
10
+ **Versions 1.1.4 and prior**
9
11
 
10
- **Version 1.0.1**
11
- + Fixes namespacing in `sidekiq-status/testing/inline`
12
-
13
- **Version 1.0.0**
14
- + Version number bumped to indicate stable release
15
-
16
- **Version 0.8.1**
17
- + Avoids transient celluloid dependency in Sidekiq < 5.x
18
-
19
- **Version 0.8.0**
20
- + Properly ignores jobs that do not have `Sidekiq::Status::Worker` included
21
- + Honors custom job expirations for ActiveJob jobs
22
- + Adds a `:retrying` status
23
- + Adds remove / retry buttons to the index page
24
- + Server middleware will now catches all exception types
25
- + Changes where server middleware is inserted in the chain
26
- + Reduces the amount of Redis calls made
27
- + Adds pagination / per page setting
28
- + Restores column sorting functionality
29
-
30
- **Version 0.7.0**
31
- + Sidekiq 4.2 and 5 now supported
32
- + Added full support for ActiveJob
33
- + Updated Web UI
34
- + Styling updated to stay consistent with Sidekiq UI
35
- + Added header sorting
36
- + Fixed argument formatting
37
- + Times now display using natural language via ChronicDuration
38
- + Test suite fixed
39
-
40
- **Version 0.6.0**
41
- + Updated Web UI
42
- + Will have all job statuses, previously it was showing only :working status
43
- + Bootstrap labels instead of badges for status
44
- + Added Arguments column to statuses page
45
- + New :interrupted status added
46
- + Added way to specify :expiration for Sidekiq::Status::ClientMiddleware
47
- + Bug fixes & Code cleanup
48
-
49
- **Version 0.5.3**
50
- + some tweaks in web UI, separate Redis namespace
51
-
52
- **Version 0.5.2**
53
- + Sidekiq versions up to 3.3.* supported, jobs sorting options in web UI, more ruby versions
54
-
55
- **Version 0.5.1**
56
- + dependencies versions requirements relaxed
57
-
58
- **Version 0.5.0**
59
- + Sidekiq v3 support, Redis pools support
60
-
61
- **Version 0.4.0**
62
- + WebUI added, per-worker expiration setting enabled
12
+ See https://github.com/utgarda/sidekiq-status/blob/master/CHANGELOG.md.
data/README.md CHANGED
@@ -1,16 +1,11 @@
1
1
  # Sidekiq::Status
2
- [![Gem Version](https://badge.fury.io/rb/sidekiq-status.svg)](http://badge.fury.io/rb/sidekiq-status)
3
- [![Code Climate](https://codeclimate.com/github/utgarda/sidekiq-status.svg)](https://codeclimate.com/github/utgarda/sidekiq-status)
4
- [![Build Status](https://secure.travis-ci.org/utgarda/sidekiq-status.svg)](http://travis-ci.org/utgarda/sidekiq-status)
5
- [![Dependency Status](https://gemnasium.com/utgarda/sidekiq-status.svg)](https://gemnasium.com/utgarda/sidekiq-status)
6
- [![Inline docs](http://inch-ci.org/github/utgarda/sidekiq-status.svg?branch=master)](http://inch-ci.org/github/utgarda/sidekiq-status)
2
+ [![Gem Version](https://badge.fury.io/rb/sidekiq-status.svg)](https://badge.fury.io/rb/sidekiq-status)
3
+ [![Build Status](https://www.travis-ci.com/kenaniah/sidekiq-status.svg?branch=main)](https://www.travis-ci.com/github/kenaniah/sidekiq-status)
4
+ [![Inline docs](https://inch-ci.org/github/kenaniah/sidekiq-status.svg?branch=main)](https://inch-ci.org/github/kenaniah/sidekiq-status)
7
5
 
8
- An extension to [Sidekiq](http://github.com/mperham/sidekiq) message processing to track your jobs. Inspired
9
- by [resque-status](http://github.com/quirkey/resque-status) and mostly copying its features, using Sidekiq's middleware.
6
+ Sidekiq-status is an extension to [Sidekiq](https://github.com/mperham/sidekiq) that tracks information about your Sidekiq and provides a UI to that purpose. It was inspired by [resque-status](https://github.com/quirkey/resque-status).
10
7
 
11
- Fully compatible with ActiveJob.
12
-
13
- Supports the latest versions of Sidekiq and all the way back to 3.x.
8
+ Requires Ruby 2.6+ and Sidekiq 5.0+ or newer.
14
9
 
15
10
  ## Installation
16
11
 
@@ -20,18 +15,18 @@ Add this line to your application's Gemfile:
20
15
  gem 'sidekiq-status'
21
16
  ```
22
17
 
23
- And then execute:
24
-
25
- ```bash
26
- $ bundle
27
- ```
28
-
29
18
  Or install it yourself as:
30
19
 
31
20
  ```bash
32
21
  gem install sidekiq-status
33
22
  ```
34
23
 
24
+ #### Migrating to Version 2.x from 1.x
25
+
26
+ Version 2.0.0 was published in order to add support for Ruby 3.0 and Sidekiq 6.x and to remove support for versions of both that are now end-of-life. **You should be able to upgrade cleanly from version 1.x to 2.x provided you are running Sidekiq 5.x or newer.**
27
+
28
+ Sidekiq-status version 1.1.4 provides support all the way back to Sidekiq 3.x and was maintained at https://github.com/utgarda/sidekiq-status/.
29
+
35
30
  ## Setup Checklist
36
31
 
37
32
  To get started:
@@ -63,9 +58,7 @@ Sidekiq.configure_server do |config|
63
58
  end
64
59
  ```
65
60
 
66
- **Note:** This method of configuration is new as of version 0.8.0.
67
-
68
- After that you can use your jobs as usual. You need to also include the `Sidekiq::Status::Worker` module in your jobs if you want the additional functionality of tracking progress and storing / retrieving job data.
61
+ Include the `Sidekiq::Status::Worker` module in your jobs if you want the additional functionality of tracking progress and storing / retrieving job data.
69
62
 
70
63
  ``` ruby
71
64
  class MyJob
@@ -78,7 +71,7 @@ class MyJob
78
71
  end
79
72
  ```
80
73
 
81
- As of version 0.8.0, _only jobs that include `Sidekiq::Status::Worker`_ will have their statuses tracked. Previous versions of this gem used to track statuses for all jobs, even when `Sidekiq::Status::Worker` was not included.
74
+ Note: _only jobs that include `Sidekiq::Status::Worker`_ will have their statuses tracked.
82
75
 
83
76
  To overwrite expiration on a per-worker basis, write an expiration method like the one below:
84
77
 
@@ -105,7 +98,7 @@ As sidekiq-status stores information about jobs in Redis, it is necessary to set
105
98
 
106
99
  As explained above, the default expiration may also be overridden on a per-job basis by defining it within the job itself via a method called `#expiration`.
107
100
 
108
- The expiration time set will be used as the [Redis expire time](http://redis.io/commands/expire), which is also known as the TTL (time to live). Once the expiration time has passed, all information about the job's status and any custom data stored via sidekiq-status will disappear.
101
+ The expiration time set will be used as the [Redis expire time](https://redis.io/commands/expire), which is also known as the TTL (time to live). Once the expiration time has passed, all information about the job's status and any custom data stored via sidekiq-status will disappear.
109
102
 
110
103
  It is advised that you set the expiration time greater than the amount of time required to complete the job.
111
104
 
@@ -131,7 +124,7 @@ Important: If you try any of the above status method after the expiration time,
131
124
 
132
125
  ### ActiveJob Support
133
126
 
134
- Version 0.7.0 has added full support for ActiveJob. The status of ActiveJob jobs will be tracked automatically.
127
+ This gem also supports ActiveJob jobs. Their status will be tracked automatically.
135
128
 
136
129
  To also enable job progress tracking and data storage features, simply add the `Sidekiq::Status::Worker` module to your base class, like below:
137
130
 
@@ -216,11 +209,11 @@ This gem provides an extension to Sidekiq's web interface with an index at `/sta
216
209
 
217
210
  ![Sidekiq Status Web](web/sidekiq-status-web.png)
218
211
 
219
- As of 0.7.0, status information for an individual job may be found at `/statuses/:job_id`.
212
+ Information for an individual job may be found at `/statuses/:job_id`.
220
213
 
221
214
  ![Sidekiq Status Web](web/sidekiq-status-single-web.png)
222
215
 
223
- As of 0.8.0, only jobs that include `Sidekiq::Status::Worker` will be reported in the web interface.
216
+ Note: _only jobs that include `Sidekiq::Status::Worker`_ will be reported in the web interface.
224
217
 
225
218
  #### Adding the Web Interface
226
219
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "sidekiq", "~> 3"
5
+ gem "sidekiq", "~> 6"
6
6
 
7
7
  gemspec path: "../"
@@ -61,7 +61,7 @@ module Sidekiq::Status
61
61
  status = :retrying
62
62
  end
63
63
  end
64
- store_status worker.jid, status, expiry
64
+ store_status(worker.jid, status, expiry) if job_class && job_class.ancestors.include?(Sidekiq::Status::Worker)
65
65
  raise
66
66
  end
67
67
 
@@ -90,7 +90,7 @@ module Sidekiq::Status::Storage
90
90
  # - end: end score (i.e. +inf or a unix timestamp)
91
91
  # - offset: current progress through (all) jobs (e.g.: 100 if you want jobs from 100 to BATCH_LIMIT)
92
92
  def schedule_batch(options)
93
- options[:conn].zrangebyscore "schedule", options[:start], options[:end], {limit: [options[:offset], BATCH_LIMIT]}
93
+ options[:conn].zrangebyscore "schedule", options[:start], options[:end], limit: [options[:offset], BATCH_LIMIT]
94
94
  end
95
95
 
96
96
  # Searches the jobs Array for the job_id
@@ -1,5 +1,5 @@
1
1
  module Sidekiq
2
2
  module Status
3
- VERSION = '1.1.1'
3
+ VERSION = '2.0.1'
4
4
  end
5
5
  end
@@ -8,6 +8,7 @@ module Sidekiq::Status
8
8
 
9
9
  DEFAULT_PER_PAGE_OPTS = [25, 50, 100].freeze
10
10
  DEFAULT_PER_PAGE = 25
11
+ COMMON_STATUS_HASH_KEYS = %w(update_time jid status worker args label pct_complete total at message)
11
12
 
12
13
  class << self
13
14
  def per_page_opts= arr
@@ -47,9 +48,14 @@ module Sidekiq::Status
47
48
  def add_details_to_status(status)
48
49
  status['label'] = status_label(status['status'])
49
50
  status["pct_complete"] ||= pct_complete(status)
51
+ status["custom"] = process_custom_data(status)
50
52
  return status
51
53
  end
52
54
 
55
+ def process_custom_data(hash)
56
+ hash.reject { |key, _| COMMON_STATUS_HASH_KEYS.include?(key) }
57
+ end
58
+
53
59
  def pct_complete(status)
54
60
  return 100 if status['status'] == 'complete'
55
61
  Sidekiq::Status::pct_complete(status['jid']) || 0
@@ -99,6 +105,10 @@ module Sidekiq::Status
99
105
  @statuses = @statuses.sort { |y,x| (x[sort_by] <=> y[sort_by]) || 1 }
100
106
  end
101
107
 
108
+ if params[:status] && params[:status] != "all"
109
+ @statuses = @statuses.select {|job_status| job_status["status"] == params[:status] }
110
+ end
111
+
102
112
  # Sidekiq pagination
103
113
  @total_size = @statuses.count
104
114
  @count = params[:per_page] ? params[:per_page].to_i : Sidekiq::Status::Web.default_per_page
@@ -126,7 +136,7 @@ module Sidekiq::Status
126
136
  job = Sidekiq::Status::get_all params['jid']
127
137
 
128
138
  if job.empty?
129
- halt [404, {"Content-Type" => "text/html"}, [erb(sidekiq_status_template(:status_not_found))]]
139
+ throw :halt, [404, {"Content-Type" => "text/html"}, [erb(sidekiq_status_template(:status_not_found))]]
130
140
  else
131
141
  @status = add_details_to_status(job)
132
142
  erb(sidekiq_status_template(:status))
@@ -138,21 +148,25 @@ module Sidekiq::Status
138
148
  job = Sidekiq::RetrySet.new.find_job(params[:jid])
139
149
  job ||= Sidekiq::DeadSet.new.find_job(params[:jid])
140
150
  job.retry if job
141
- halt [302, { "Location" => request.referer }, []]
151
+ throw :halt, [302, { "Location" => request.referer }, []]
142
152
  end
143
153
 
144
154
  # Removes a completed job from the status list
145
155
  app.delete '/statuses' do
146
156
  Sidekiq::Status.delete(params[:jid])
147
- halt [302, { "Location" => request.referer }, []]
157
+ throw :halt, [302, { "Location" => request.referer }, []]
148
158
  end
149
159
  end
150
160
  end
151
161
  end
152
162
 
153
- require 'sidekiq/web' unless defined?(Sidekiq::Web)
163
+ unless defined?(Sidekiq::Web)
164
+ require 'delegate' # Needed for sidekiq 5.x
165
+ require 'sidekiq/web'
166
+ end
167
+
154
168
  Sidekiq::Web.register(Sidekiq::Status::Web)
155
- ["per_page", "sort_by", "sort_dir"].each do |key|
169
+ ["per_page", "sort_by", "sort_dir", "status"].each do |key|
156
170
  Sidekiq::WebHelpers::SAFE_QPARAMS.push(key)
157
171
  end
158
172
  if Sidekiq::Web.tabs.is_a?(Array)
@@ -5,7 +5,7 @@ Gem::Specification.new do |gem|
5
5
  gem.authors = ['Evgeniy Tsvigun', 'Kenaniah Cerny']
6
6
  gem.email = ['utgarda@gmail.com', 'kenaniah@gmail.com']
7
7
  gem.summary = 'An extension to the sidekiq message processing to track your jobs'
8
- gem.homepage = 'http://github.com/utgarda/sidekiq-status'
8
+ gem.homepage = 'https://github.com/kenaniah/sidekiq-status'
9
9
  gem.license = 'MIT'
10
10
 
11
11
  gem.files = `git ls-files`.split($\)
@@ -14,7 +14,7 @@ Gem::Specification.new do |gem|
14
14
  gem.require_paths = ['lib']
15
15
  gem.version = Sidekiq::Status::VERSION
16
16
 
17
- gem.add_dependency 'sidekiq', '>= 3.0'
17
+ gem.add_dependency 'sidekiq', '>= 5.0'
18
18
  gem.add_dependency 'chronic_duration'
19
19
  gem.add_development_dependency 'appraisal'
20
20
  gem.add_development_dependency 'colorize'
@@ -36,21 +36,39 @@ describe Sidekiq::Status::ServerMiddleware do
36
36
  it "sets failed status when Exception raised" do
37
37
  allow(SecureRandom).to receive(:hex).once.and_return(job_id)
38
38
  start_server do
39
- expect(capture_status_updates(3) {
40
- expect(FailingHardJob.perform_async).to eq(job_id)
41
- }).to eq([job_id]*3)
39
+ expect(capture_status_updates(3) {
40
+ expect(FailingHardJob.perform_async).to eq(job_id)
41
+ }).to eq([job_id]*3)
42
42
  end
43
43
  expect(redis.hget("sidekiq:status:#{job_id}", :status)).to eq('failed')
44
44
  expect(Sidekiq::Status::failed?(job_id)).to be_truthy
45
45
  end
46
46
 
47
+ context "when Sidekiq::Status::Worker is not included in the job" do
48
+ it "should not set a failed status" do
49
+ allow(SecureRandom).to receive(:hex).once.and_return(job_id)
50
+ start_server do
51
+ expect(FailingNoStatusJob.perform_async).to eq(job_id)
52
+ end
53
+ expect(redis.hget("sidekiq:status:#{job_id}", :status)).to be_nil
54
+ end
55
+
56
+ it "should not set any status when Exception raised" do
57
+ allow(SecureRandom).to receive(:hex).once.and_return(job_id)
58
+ start_server do
59
+ expect(FailingHardNoStatusJob.perform_async).to eq(job_id)
60
+ end
61
+ expect(redis.hget("sidekiq:status:#{job_id}", :status)).to be_nil
62
+ end
63
+ end
64
+
47
65
  context "sets interrupted status" do
48
66
  it "on system exit signal" do
49
67
  allow(SecureRandom).to receive(:hex).once.and_return(job_id)
50
68
  start_server do
51
- expect(capture_status_updates(3) {
52
- expect(ExitedJob.perform_async).to eq(job_id)
53
- }).to eq([job_id]*3)
69
+ expect(capture_status_updates(3) {
70
+ expect(ExitedJob.perform_async).to eq(job_id)
71
+ }).to eq([job_id]*3)
54
72
  end
55
73
  expect(redis.hget("sidekiq:status:#{job_id}", :status)).to eq('interrupted')
56
74
  expect(Sidekiq::Status::interrupted?(job_id)).to be_truthy
@@ -13,6 +13,7 @@ describe 'sidekiq status web' do
13
13
  end
14
14
 
15
15
  before do
16
+ env 'rack.session', csrf: Base64.urlsafe_encode64('token')
16
17
  client_middleware
17
18
  allow(SecureRandom).to receive(:hex).and_return(job_id)
18
19
  end
@@ -31,6 +32,27 @@ describe 'sidekiq status web' do
31
32
  expect(last_response.body).to match(/working/)
32
33
  end
33
34
 
35
+ it 'allows filtering the list of jobs by status' do
36
+ capture_status_updates(2) do
37
+ LongJob.perform_async(0.5)
38
+ end
39
+
40
+ get '/statuses?status=working'
41
+ expect(last_response).to be_ok
42
+ expect(last_response.body).to match(/#{job_id}/)
43
+ expect(last_response.body).to match(/LongJob/)
44
+ expect(last_response.body).to match(/working/)
45
+ end
46
+
47
+ it 'allows filtering the list of jobs by completed status' do
48
+ capture_status_updates(2) do
49
+ LongJob.perform_async(0.5)
50
+ end
51
+ get '/statuses?status=completed'
52
+ expect(last_response).to be_ok
53
+ expect(last_response.body).to_not match(/LongJob/)
54
+ end
55
+
34
56
  it 'shows a single job in progress' do
35
57
  capture_status_updates(2) do
36
58
  LongJob.perform_async(1, 'another argument')
@@ -43,6 +65,17 @@ describe 'sidekiq status web' do
43
65
  expect(last_response.body).to match(/working/)
44
66
  end
45
67
 
68
+ it 'shows custom data for a single job' do
69
+ capture_status_updates(3) do
70
+ CustomDataJob.perform_async
71
+ end
72
+
73
+ get "/statuses/#{job_id}"
74
+ expect(last_response).to be_ok
75
+ expect(last_response.body).to match(/mister_cat/)
76
+ expect(last_response.body).to match(/meow/)
77
+ end
78
+
46
79
  it 'show an error when the requested job ID is not found' do
47
80
  get '/statuses/12345'
48
81
  expect(last_response).to be_not_found
@@ -105,7 +105,7 @@ describe Sidekiq::Status do
105
105
  second_job = LongJob.perform_in(3600)
106
106
  expect(second_job).to eq(job_id_1)
107
107
 
108
- initial_schedule = redis.zrange "schedule", 0, -1, {withscores: true}
108
+ initial_schedule = redis.zrange "schedule", 0, -1, withscores: true
109
109
  expect(initial_schedule.size).to be(2)
110
110
  expect(initial_schedule.select {|scheduled_job| JSON.parse(scheduled_job[0])["jid"] == job_id }.size).to be(1)
111
111
 
@@ -113,7 +113,7 @@ describe Sidekiq::Status do
113
113
  # Unused, therefore unfound => false
114
114
  expect(Sidekiq::Status.cancel(unused_id)).to be_falsey
115
115
 
116
- remaining_schedule = redis.zrange "schedule", 0, -1, {withscores: true}
116
+ remaining_schedule = redis.zrange "schedule", 0, -1, withscores: true
117
117
  expect(remaining_schedule.size).to be(initial_schedule.size - 1)
118
118
  expect(remaining_schedule.select {|scheduled_job| JSON.parse(scheduled_job[0])["jid"] == job_id }.size).to be(0)
119
119
  end
@@ -126,14 +126,14 @@ describe Sidekiq::Status do
126
126
  returned_job_id = LongJob.perform_at(scheduled_time)
127
127
  expect(returned_job_id).to eq(job_id)
128
128
 
129
- initial_schedule = redis.zrange "schedule", 0, -1, {withscores: true}
129
+ initial_schedule = redis.zrange "schedule", 0, -1, withscores: true
130
130
  expect(initial_schedule.size).to be(1)
131
131
  # wrong time, therefore unfound => false
132
132
  expect(Sidekiq::Status.cancel(returned_job_id, (scheduled_time + 1))).to be_falsey
133
- expect((redis.zrange "schedule", 0, -1, {withscores: true}).size).to be(1)
133
+ expect((redis.zrange "schedule", 0, -1, withscores: true).size).to be(1)
134
134
  # same id, same time, deletes
135
135
  expect(Sidekiq::Status.cancel(returned_job_id, (scheduled_time))).to be_truthy
136
- expect(redis.zrange "schedule", 0, -1, {withscores: true}).to be_empty
136
+ expect(redis.zrange "schedule", 0, -1, withscores: true).to be_empty
137
137
  end
138
138
  end
139
139
  end
@@ -10,6 +10,16 @@ class StubJob
10
10
  end
11
11
  end
12
12
 
13
+ class StubNoStatusJob
14
+ include Sidekiq::Worker
15
+
16
+ sidekiq_options 'retry' => false
17
+
18
+ def perform(*args)
19
+ end
20
+ end
21
+
22
+
13
23
  class ExpiryJob < StubJob
14
24
  def expiration
15
25
  15
@@ -31,6 +41,13 @@ class DataJob < StubJob
31
41
  end
32
42
  end
33
43
 
44
+ class CustomDataJob < StubJob
45
+ def perform
46
+ store({mister_cat: 'meow'})
47
+ sleep 0.5
48
+ end
49
+ end
50
+
34
51
  class ProgressJob < StubJob
35
52
  def perform
36
53
  total 500
@@ -62,6 +79,12 @@ class FailingJob < StubJob
62
79
  end
63
80
  end
64
81
 
82
+ class FailingNoStatusJob < StubNoStatusJob
83
+ def perform
84
+ raise StandardError
85
+ end
86
+ end
87
+
65
88
  class RetryAndFailJob < StubJob
66
89
  sidekiq_options retry: 1
67
90
 
@@ -76,6 +99,12 @@ class FailingHardJob < StubJob
76
99
  end
77
100
  end
78
101
 
102
+ class FailingHardNoStatusJob < StubNoStatusJob
103
+ def perform
104
+ raise Exception
105
+ end
106
+ end
107
+
79
108
  class ExitedJob < StubJob
80
109
  def perform
81
110
  raise SystemExit
data/web/views/status.erb CHANGED
@@ -28,7 +28,7 @@
28
28
  </div>
29
29
  </div>
30
30
 
31
- <div class="panel panel-default">
31
+ <div class="panel panel-default" style="background-color: inherit">
32
32
  <div class="panel-body">
33
33
  <h4><%= @status["worker"] %></h4>
34
34
 
@@ -65,6 +65,24 @@
65
65
  </p>
66
66
  </div>
67
67
  </div>
68
+
69
+ <% if @status["custom"].any? %>
70
+ <hr>
71
+ <% @status["custom"].each do |key, val| %>
72
+ <div class="row">
73
+ <div class="col-sm-2">
74
+ <strong><%= key %></strong>
75
+ </div>
76
+ <div class="col-sm-10">
77
+ <% if val && val.include?("\n") %>
78
+ <pre><%= val %></pre>
79
+ <% else %>
80
+ <p><%= val || "<i>none</i>" %></p>
81
+ <% end %>
82
+ </div>
83
+ </div>
84
+ <% end %>
85
+ <% end %>
68
86
  </div>
69
87
  </div>
70
88
 
@@ -38,7 +38,7 @@
38
38
  display: flex;
39
39
  align-items: center;
40
40
  }
41
- .nav-container .per-page {
41
+ .nav-container .per-page, .filter-status {
42
42
  display: flex;
43
43
  align-items: center;
44
44
  margin: 20px 0 20px 10px;
@@ -57,6 +57,15 @@ function setPerPage(select){
57
57
  <h3 class="wi">Recent job statuses</h3>
58
58
  <div class="nav-container">
59
59
  <%= erb :_paging, locals: { url: "#{root_path}statuses" } %>
60
+ <div class="filter-status">
61
+ Filter Status:
62
+ <select class="form-control" onchange="setPerPage(this)">
63
+ <% (['all', 'complete', 'failed', 'interrupted', 'queued', 'retrying', 'stopped', 'working']).each do |status| %>
64
+ <option data-url="?<%= qparams(status: status)%>" value="<%= status %>" <%= 'selected="selected"' if status == (params[:status]) %>><%= status %></option>
65
+ <% end %>
66
+ </select>
67
+ </div>
68
+
60
69
  <div class="per-page">
61
70
  Per page:
62
71
  <select class="form-control" onchange="setPerPage(this)">
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-status
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evgeniy Tsvigun
8
8
  - Kenaniah Cerny
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-12-19 00:00:00.000000000 Z
12
+ date: 2021-06-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sidekiq
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: '3.0'
20
+ version: '5.0'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: '3.0'
27
+ version: '5.0'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: chronic_duration
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -123,7 +123,7 @@ dependencies:
123
123
  - - ">="
124
124
  - !ruby/object:Gem::Version
125
125
  version: '0'
126
- description:
126
+ description:
127
127
  email:
128
128
  - utgarda@gmail.com
129
129
  - kenaniah@gmail.com
@@ -132,6 +132,7 @@ extensions: []
132
132
  extra_rdoc_files: []
133
133
  files:
134
134
  - ".gitignore"
135
+ - ".gitlab-ci.yml"
135
136
  - ".rspec"
136
137
  - ".travis.yml"
137
138
  - Appraisals
@@ -140,9 +141,8 @@ files:
140
141
  - LICENSE
141
142
  - README.md
142
143
  - Rakefile
143
- - gemfiles/sidekiq_3.x.gemfile
144
- - gemfiles/sidekiq_4.x.gemfile
145
144
  - gemfiles/sidekiq_5.x.gemfile
145
+ - gemfiles/sidekiq_6.x.gemfile
146
146
  - lib/sidekiq-status.rb
147
147
  - lib/sidekiq-status/client_middleware.rb
148
148
  - lib/sidekiq-status/server_middleware.rb
@@ -167,11 +167,11 @@ files:
167
167
  - web/views/status.erb
168
168
  - web/views/status_not_found.erb
169
169
  - web/views/statuses.erb
170
- homepage: http://github.com/utgarda/sidekiq-status
170
+ homepage: https://github.com/kenaniah/sidekiq-status
171
171
  licenses:
172
172
  - MIT
173
173
  metadata: {}
174
- post_install_message:
174
+ post_install_message:
175
175
  rdoc_options: []
176
176
  require_paths:
177
177
  - lib
@@ -186,9 +186,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
186
186
  - !ruby/object:Gem::Version
187
187
  version: '0'
188
188
  requirements: []
189
- rubyforge_project:
190
- rubygems_version: 2.7.6
191
- signing_key:
189
+ rubygems_version: 3.2.15
190
+ signing_key:
192
191
  specification_version: 4
193
192
  summary: An extension to the sidekiq message processing to track your jobs
194
193
  test_files:
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "sidekiq", "~> 4"
6
-
7
- gemspec path: "../"