sidekiq-reset_statistics 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/LICENSE.txt +1 -1
- data/README.md +1 -1
- data/lib/sidekiq-reset_statistics/version.rb +1 -1
- data/lib/sidekiq-reset_statistics/web.rb +13 -2
- data/spec/sidekiq-reset_statistics/version_spec.rb +1 -1
- data/spec/sidekiq-reset_statistics/web_spec.rb +57 -10
- data/web/views/reset_statistics.erb +6 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7eb64a314a3efea7e626b77b0a7e1efba7bf69ea
|
4
|
+
data.tar.gz: 06f12568a63d1abcf34cf53fa157808b95c7b0a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cab24524b9f8388d64b7555f956e7b21cf3ca59daf8b362b72b6a3b6f2f434c6414a3285d150245235992eced901db9bfe78d45542b03442f0445a4e08b64b98
|
7
|
+
data.tar.gz: 2deefca85797f5b223626074aaa0547af9d0f2b5bfec254118775d09d34cd9e15ee77e6fb61e643e54733800493231b7e0bdccde12b4a3cfa955c992fc1a683d
|
data/CHANGELOG.md
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -10,10 +10,21 @@ module Sidekiq
|
|
10
10
|
end
|
11
11
|
|
12
12
|
app.post "/reset-statistics" do
|
13
|
-
Sidekiq::Stats.new
|
13
|
+
stats = Sidekiq::Stats.new
|
14
|
+
resets = params.values.grep(/Reset (?!All)/)
|
15
|
+
|
16
|
+
if resets.empty?
|
17
|
+
stats.reset
|
18
|
+
elsif stats.method(:reset).arity != -1
|
19
|
+
raise StandardError, "Version mismatch. Please upgrade Sidekiq."
|
20
|
+
else
|
21
|
+
counts = resets.map {|r| r.split.last.downcase }
|
22
|
+
stats.reset(*counts)
|
23
|
+
end
|
24
|
+
|
14
25
|
redirect root_path
|
15
26
|
end
|
16
27
|
end
|
17
28
|
end
|
18
29
|
end
|
19
|
-
end
|
30
|
+
end
|
@@ -3,27 +3,74 @@ require 'spec_helper'
|
|
3
3
|
describe Sidekiq::ResetStatistics::Web do
|
4
4
|
include Rack::Test::Methods
|
5
5
|
|
6
|
-
|
7
|
-
Sidekiq.redis { |conn| conn.flushdb }
|
8
|
-
end
|
6
|
+
STATS = %w(processed failed).freeze unless defined?(STATS)
|
9
7
|
|
10
8
|
def app
|
11
9
|
@app ||= Sidekiq::Web
|
12
10
|
end
|
13
11
|
|
12
|
+
before do
|
13
|
+
Sidekiq.redis do |conn|
|
14
|
+
conn.flushdb
|
15
|
+
STATS.each { |stat| conn.set("stat:#{stat}", 5) }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
14
19
|
it 'should display the index page' do
|
15
20
|
get '/reset-statistics'
|
16
21
|
last_response.status.should == 200
|
17
22
|
end
|
18
23
|
|
19
|
-
it 'should reset statistics in Sidekiq' do
|
24
|
+
it 'should reset all statistics in Sidekiq by default' do
|
25
|
+
post '/reset-statistics'
|
26
|
+
last_response.status.should == 302
|
27
|
+
|
28
|
+
Sidekiq.redis do |conn|
|
29
|
+
STATS.each { |stat| conn.get("stat:#{stat}").should == '0' }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should reset all statistics in Sidekiq when asked' do
|
34
|
+
post '/reset-statistics', :reset_all => 'Reset All'
|
35
|
+
last_response.status.should == 302
|
36
|
+
|
20
37
|
Sidekiq.redis do |conn|
|
21
|
-
conn.
|
22
|
-
|
23
|
-
|
38
|
+
STATS.each { |stat| conn.get("stat:#{stat}").should == '0' }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
STATS.each do |stat|
|
43
|
+
it "should reset #{stat} when asked" do
|
44
|
+
post '/reset-statistics', "reset_#{stat}" => "Reset #{stat.capitalize}"
|
24
45
|
last_response.status.should == 302
|
25
|
-
|
26
|
-
|
46
|
+
|
47
|
+
Sidekiq.redis do |conn|
|
48
|
+
conn.get("stat:#{stat}").should == '0'
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context 'version mismatch' do
|
54
|
+
before do
|
55
|
+
method_class = String.method(:new).class
|
56
|
+
instance_method_class = String.instance_method(:size).class
|
57
|
+
method_class.any_instance.stub(:arity => 0)
|
58
|
+
instance_method_class.any_instance.stub(:arity => 0)
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'should not raise an error when requested action is compatible with sidekiq' do
|
62
|
+
post '/reset-statistics', :reset_all => 'Reset All'
|
63
|
+
last_response.status.should == 302
|
64
|
+
|
65
|
+
Sidekiq.redis do |conn|
|
66
|
+
STATS.each { |stat| conn.get("stat:#{stat}").should == '0' }
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'should raise an error when requested action is incompatible with sidekiq' do
|
71
|
+
post '/reset-statistics', :reset_foo => 'Reset Foo'
|
72
|
+
last_response.status.should == 500
|
73
|
+
last_response.errors.should include('Version mismatch. Please upgrade Sidekiq')
|
27
74
|
end
|
28
75
|
end
|
29
|
-
end
|
76
|
+
end
|
@@ -1,3 +1,7 @@
|
|
1
1
|
<form action="<%= root_path %>reset-statistics" method="post">
|
2
|
-
|
3
|
-
|
2
|
+
<% if Sidekiq::Stats.instance_method(:reset).arity == -1 %>
|
3
|
+
<input class="btn btn-danger pull-left" type="submit" name="reset_processed" value="Reset Processed" data-confirm="<%= t('AreYouSure') %>"/>
|
4
|
+
<input class="btn btn-danger pull-left" type="submit" name="reset_failed" value="Reset Failed" data-confirm="<%= t('AreYouSure') %>"/>
|
5
|
+
<% end %>
|
6
|
+
<input class="btn btn-danger pull-left" type="submit" name="reset_all" value="Reset All" data-confirm="<%= t('AreYouSure') %>"/>
|
7
|
+
</form>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq-reset_statistics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Czarnecki
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sidekiq
|
@@ -122,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
122
122
|
version: '0'
|
123
123
|
requirements: []
|
124
124
|
rubyforge_project: sidekiq-reset_statistics
|
125
|
-
rubygems_version: 2.0.
|
125
|
+
rubygems_version: 2.0.5
|
126
126
|
signing_key:
|
127
127
|
specification_version: 4
|
128
128
|
summary: Adds a tab to your Sidekiq dashboard to allow you to reset Sidekiq statistics
|