Skip to content
Browse files

counter reset adjustments

  • Loading branch information...
1 parent 90937df commit e0bf8112e842647218bbc63b6881e66b1a803ca0 @mhfs committed Dec 30, 2012
Showing with 13 additions and 15 deletions.
  1. +1 −0 CHANGELOG.md
  2. +1 −1 lib/sidekiq/failures/views/failures.slim
  3. +1 −1 lib/sidekiq/failures/web_extension.rb
  4. +10 −13 test/web_extension_test.rb
View
1 CHANGELOG.md
@@ -5,6 +5,7 @@
Celluloid actors) except for inside a Sidekiq server context (@cheald)
* Fix pagination bug
* Add failures default mode option (@kbaum)
+ * Add checkbox option to reset failed counter (@krasnoukhov)
## 0.0.3
View
2 lib/sidekiq/failures/views/failures.slim
@@ -32,7 +32,7 @@ header.row
input.btn.btn-danger.btn-small type="submit" name="delete" value="Clear All"
label class="checkbox"
input type="checkbox" name="counter" value="true"
- = "clear counter"
+ = "reset failed counter"
.span4
== slim :_paging, :locals => { :url => "#{root_path}failures#@name" }
- else
View
2 lib/sidekiq/failures/web_extension.rb
@@ -23,7 +23,7 @@ def find_template(view, *a, &b)
Sidekiq.redis {|c|
c.multi do
c.del("failed")
- c.del("stat:failed") if params["counter"]
+ c.set("stat:failed", 0) if params["counter"]
end
}
View
23 test/web_extension_test.rb
@@ -49,12 +49,11 @@ def app
last_response.body.must_match /failures\/remove/
last_response.body.must_match /method=\"post/
last_response.body.must_match /Clear All/
+ last_response.body.must_match /reset failed counter/
end
it 'can remove all failures without clearing counter' do
- Sidekiq.redis do |c|
- assert_equal c.get("stat:failed"), "1"
- end
+ assert_equal failed_count, "1"
last_response.body.must_match /HardWorker/
@@ -66,15 +65,11 @@ def app
last_response.status.must_equal 200
last_response.body.must_match /No failed jobs found/
- Sidekiq.redis do |c|
- assert_equal c.get("stat:failed"), "1"
- end
+ assert_equal failed_count, "1"
end
it 'can remove all failures and clear counter' do
- Sidekiq.redis do |c|
- assert_equal c.get("stat:failed"), "1"
- end
+ assert_equal failed_count, "1"
last_response.body.must_match /HardWorker/
@@ -86,9 +81,7 @@ def app
last_response.status.must_equal 200
last_response.body.must_match /No failed jobs found/
- Sidekiq.redis do |c|
- assert_nil c.get("stat:failed")
- end
+ assert_equal failed_count, "0"
end
end
@@ -106,9 +99,13 @@ def create_sample_failure
Sidekiq.redis do |c|
c.multi do
c.rpush("failed", Sidekiq.dump_json(data))
- c.incrby("stat:failed", 1)
+ c.set("stat:failed", 1)
end
end
end
+
+ def failed_count
+ Sidekiq.redis { |c| c.get("stat:failed") }
+ end
end
end

0 comments on commit e0bf811

Please sign in to comment.
Something went wrong with that request. Please try again.