sidekiq-expected_failures 0.2.3 → 0.2.4

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: 0c5ff08635fbb2ba6755c5db477d062def09307d
4
- data.tar.gz: 4c871c3c875ff8fdfaf7dbb6fc6508e2e8b9aa44
3
+ metadata.gz: 9e25fbc9e0f8ec213cdd6737e9a512829b84bd0c
4
+ data.tar.gz: 0c1d1cfdf2fa3be4dfdadd1be0cf9ccba959f580
5
5
  SHA512:
6
- metadata.gz: cb77f825aaac8dbca440a8af215efe6b1ce991112ab103fde6b171a6442754d8a635c9c40e6f760aeef5175021a13f31b9e07588cbb160a5488e27db5b41dd10
7
- data.tar.gz: b7dcf1451697e9d872ac843265629e094640ca08d383327f3cdb244acb949bc211d304d972c143fbb5cb93fb818c4e646f50657b8ca29122734326bf3a8cacb6
6
+ metadata.gz: a18b6fea8db4e17c0110a3c52e27a9ae4cd055804536f7e6d1b9d8aa3d2e87c811a09484cca87a30559649caf91b23ff6cf440de561dec0d205f861122ce3f0c
7
+ data.tar.gz: 3e01243030006b880b7d421d994a867002b8030129d99672c3eb19e3695d8188c455e9a8631de8c3d36c9e52e27a704c851df974a117d550a677065bdf8a5044
data/.travis.yml CHANGED
@@ -2,11 +2,11 @@ language: ruby
2
2
 
3
3
  rvm:
4
4
  - 1.9.3
5
- - jruby-19mode
6
- - rbx
5
+ - jruby-1.7.11
6
+ - rbx-2.2.9
7
7
  - 2.0.0
8
8
  - 2.1.0
9
- - ruby-head
9
+ - 2.1.2
10
10
 
11
11
  services:
12
12
  - redis-server
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.2.4
2
+
3
+ - `Sidekiq::ExpectedFailures.clear_old` can now accept argument - will remove failures
4
+ that are n days old (1 by default) - useful if you want to clear some of old failures
5
+ using cronjob
6
+
1
7
  ## 0.2.3
2
8
 
3
9
  - removed (unnecessary) dependency on `Sidekiq::Util` (now Sidekiq 3.0 compatible)
data/README.md CHANGED
@@ -77,7 +77,7 @@ Just be sure to load this one after `sidekiq-failures`, otherwise failed jobs wi
77
77
  At the moment you have 3 public methods in `Sidekiq::ExpectedFailures` module:
78
78
 
79
79
  - `clear_counters` - clears all counters (as I mentioned - it's stored inside single redis hash, but I doubt anyone would like to log more than 500 different exceptions, right?)
80
- - `clear_old` - clears failed jobs older than today
80
+ - `clear_old(days_ago)` - clears failed jobs older than days_ago days (this is 1 by default)
81
81
  - `clear_all` - clears all failed jobs
82
82
 
83
83
  This might change in the future to something more sane.
@@ -1,5 +1,5 @@
1
1
  module Sidekiq
2
2
  module ExpectedFailures
3
- VERSION = "0.2.3"
3
+ VERSION = "0.2.4"
4
4
  end
5
5
  end
@@ -35,8 +35,8 @@ module Sidekiq
35
35
  clear(dates.keys)
36
36
  end
37
37
 
38
- def self.clear_old
39
- range = dates.keys.delete_if { |d| Date.parse(d) > Date.today.prev_day }
38
+ def self.clear_old(days_ago = 1)
39
+ range = dates.keys.delete_if { |d| Date.parse(d) > Date.today.prev_day(days_ago) }
40
40
  clear(range)
41
41
  end
42
42
 
@@ -0,0 +1,47 @@
1
+ require "test_helper"
2
+
3
+ module Sidekiq
4
+ module ExpectedFailures
5
+ describe "clear_old (helper method)" do
6
+ before do
7
+ Sidekiq.redis = REDIS
8
+ Sidekiq.redis {|c| c.flushdb }
9
+ Timecop.freeze(Time.local(2014, 6, 10))
10
+
11
+ # fresh failure
12
+ Sidekiq.redis do |c|
13
+ c.lpush("expected:2014-06-10", Sidekiq.dump_json({}))
14
+ c.sadd("expected:dates", "2014-06-10")
15
+ end
16
+
17
+ # 1 day old
18
+ Sidekiq.redis do |c|
19
+ c.lpush("expected:2014-06-09", Sidekiq.dump_json({}))
20
+ c.sadd("expected:dates", "2014-06-09")
21
+ end
22
+
23
+ # 3 days old
24
+ Sidekiq.redis do |c|
25
+ c.lpush("expected:2014-06-07", Sidekiq.dump_json({}))
26
+ c.sadd("expected:dates", "2014-06-07")
27
+ end
28
+ end
29
+
30
+ after do
31
+ Timecop.return
32
+ end
33
+
34
+ it "clears failures older than 1 day by default" do
35
+ Sidekiq::ExpectedFailures.clear_old
36
+ assert_equal ["2014-06-10"], redis("smembers", "expected:dates")
37
+ assert_nil redis("get", "expected:2014-06-09")
38
+ assert_nil redis("get", "expected:2014-06-07")
39
+ end
40
+
41
+ it "can be called with days_old argument" do
42
+ Sidekiq::ExpectedFailures.clear_old(2)
43
+ assert_equal ["2014-06-09", "2014-06-10"], redis("smembers", "expected:dates").sort
44
+ end
45
+ end
46
+ end
47
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-expected_failures
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rafal Wojsznis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-07 00:00:00.000000000 Z
11
+ date: 2014-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sidekiq
@@ -143,6 +143,7 @@ files:
143
143
  - lib/sidekiq/expected_failures/version.rb
144
144
  - lib/sidekiq/expected_failures/web.rb
145
145
  - sidekiq-expected_failures.gemspec
146
+ - test/lib/expected_failures_test.rb
146
147
  - test/lib/middleware_test.rb
147
148
  - test/lib/web_test.rb
148
149
  - test/test_helper.rb
@@ -176,6 +177,7 @@ specification_version: 4
176
177
  summary: If you don't rely on sidekiq' retry behavior, you handle exceptions on your
177
178
  own and want to keep track of them - this thing is for you.
178
179
  test_files:
180
+ - test/lib/expected_failures_test.rb
179
181
  - test/lib/middleware_test.rb
180
182
  - test/lib/web_test.rb
181
183
  - test/test_helper.rb