sidekiq-history 0.0.4 → 0.0.5

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: e711beba2411f9370535f25a55b155b4d0a8c9e3
4
- data.tar.gz: 4faacedaa5eea21af2f434241a347204399e4d99
3
+ metadata.gz: 6706f6114baf8bd2857f5a026db7c2a10a1e8b28
4
+ data.tar.gz: 551c77a01e74c87c36d954c6935fa157a1030146
5
5
  SHA512:
6
- metadata.gz: e6683e24506da4e4ee7ee784a56a898efc1d168b1cad95cfc2ba8c6a30f9026c2c992dfb94bf3b6ea316205a0cdf49380cb340f3207649566786125b37abad9b
7
- data.tar.gz: f999ee580abacebe22811b5b057eb6cb1c84a5c92977d0b44c35f10612728342da7e8ce7a167863575f296ad1668fe41149aed25fa50b635ac786915e7dc4d26
6
+ metadata.gz: 1ca66b193bd21ac805c9eccbb12094d7558e0858bd064fa7fda76d2171fc58e32e0741351665ab60fb32b7424c9ccabbaf43d62b7f55c1085dc90e3973d50a01
7
+ data.tar.gz: 02fef2c9d2aa38a22e497d0a94eb6d536ae30df0281c68574dade96773093276975bdb4a1f4cf233291e380ff4ec549f88a924b19ced1a04e3bd8cba5663aad1
@@ -26,9 +26,17 @@ module Sidekiq
26
26
  end
27
27
 
28
28
  def self.count
29
- Sidekiq.redis { |r| r.llen(LIST_KEY) }
29
+ Sidekiq.redis { |r| r.zcard(LIST_KEY) }
30
30
  end
31
+
32
+ class HistorySet < Sidekiq::JobSet
33
+ def initialize
34
+ super LIST_KEY
35
+ end
36
+ end
37
+
31
38
  end
39
+
32
40
  end
33
41
 
34
42
  Sidekiq.configure_server do |config|
@@ -19,9 +19,21 @@ module Sidekiq
19
19
  }
20
20
 
21
21
  Sidekiq.redis do |conn|
22
- conn.lpush(LIST_KEY, Sidekiq.dump_json(data))
22
+ # migration of list to set for backwards compatibility after v0.0.4
23
+ if conn.type(LIST_KEY) == 'list'
24
+ length = conn.llen(LIST_KEY)
25
+ list = conn.lrange(LIST_KEY, 0, length)
26
+ conn.del(LIST_KEY)
27
+ list.each do |entry|
28
+ migrated_data = JSON.parse(entry)
29
+ conn.zadd(LIST_KEY, data[:started_at].to_f, Sidekiq.dump_json(migrated_data))
30
+ end
31
+ end
32
+
33
+ # regular storage of history
34
+ conn.zadd(LIST_KEY, data[:started_at].to_f, Sidekiq.dump_json(data))
23
35
  unless Sidekiq.history_max_count == false
24
- conn.ltrim(LIST_KEY, 0, Sidekiq.history_max_count - 1)
36
+ conn.zremrangebyrank(LIST_KEY, 0, -(Sidekiq.history_max_count + 1))
25
37
  end
26
38
  end
27
39
 
@@ -1,5 +1,5 @@
1
1
  module Sidekiq
2
2
  module History
3
- VERSION = "0.0.4"
3
+ VERSION = "0.0.5"
4
4
  end
5
5
  end
@@ -12,11 +12,25 @@ module Sidekiq
12
12
  render(:erb, File.read("#{ROOT}/views/history.erb"))
13
13
  end
14
14
 
15
- app.post "/history/remove" do
15
+ app.post '/history/remove' do
16
16
  Sidekiq::History.reset_history(counter: params['counter'])
17
17
  redirect("#{root_path}history")
18
18
  end
19
19
 
20
+ app.get '/filter/history' do
21
+ return redirect "#{root_path}history" unless params[:substr]
22
+
23
+ @messages = search(HistorySet.new, params[:substr])
24
+ render(:erb, File.read("#{ROOT}/views/history.erb"))
25
+ end
26
+
27
+ app.post '/filter/history' do
28
+ return redirect "#{root_path}history" unless params[:substr]
29
+
30
+ @messages = search(HistorySet.new, params[:substr])
31
+ render(:erb, File.read("#{ROOT}/views/history.erb"))
32
+ end
33
+
20
34
  app.settings.locales << File.expand_path('locales', ROOT)
21
35
  end
22
36
  end
@@ -7,6 +7,7 @@
7
7
  <%= erb :_paging, :locals => { :url => "#{root_path}history" } %>
8
8
  </div>
9
9
  <% end %>
10
+ <%= filtering('history') %>
10
11
  </header>
11
12
 
12
13
  <% if @messages.size > 0 %>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-history
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Russ Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-08 00:00:00.000000000 Z
11
+ date: 2015-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sidekiq