1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00

Web UI bug fixes, 0.9.1 [fixes #81]

This commit is contained in:
Mike Perham 2012-03-17 09:41:24 -07:00
parent 727c5af21b
commit 18a458bf1f
7 changed files with 27 additions and 10 deletions

View file

@ -1,3 +1,8 @@
0.9.1
-----------
- Fix missed deprecations, poor method name in web UI
0.9.0
-----------

View file

@ -3,6 +3,7 @@ require 'sidekiq/client'
require 'sidekiq/worker'
require 'sidekiq/rails'
require 'sidekiq/redis_connection'
require 'sidekiq/util'
require 'sidekiq/extensions/action_mailer'
require 'sidekiq/extensions/active_record'

View file

@ -1,3 +1,3 @@
module Sidekiq
VERSION = "0.9.0"
VERSION = "0.9.1"
end

View file

@ -38,7 +38,7 @@ module Sidekiq
helpers do
def workers
@workers ||= begin
Sidekiq.redis.with_connection do |conn|
Sidekiq.redis do |conn|
conn.smembers('workers').map do |w|
msg = conn.get("worker:#{w}")
msg = MultiJson.decode(msg) if msg
@ -49,15 +49,15 @@ module Sidekiq
end
def processed
Sidekiq.redis.get('stat:processed') || 0
Sidekiq.redis { |conn| conn.get('stat:processed') } || 0
end
def failed
Sidekiq.redis.get('stat:failed') || 0
Sidekiq.redis { |conn| conn.get('stat:failed') } || 0
end
def queues
Sidekiq.redis.with_connection do |conn|
Sidekiq.redis do |conn|
conn.smembers('queues').map do |q|
[q, conn.llen("queue:#{q}") || 0]
end.sort { |x,y| x[1] <=> y[1] }
@ -65,14 +65,14 @@ module Sidekiq
end
def location
Sidekiq.redis.client.location
Sidekiq.redis { |conn| conn.client.location }
end
def root_path
"#{env['SCRIPT_NAME']}/"
end
def status
def current_status
return 'down' if workers.size == 0
return 'idle' if workers.size > 0 && workers.map { |x| x[1] }.compact.size == 0
return 'active'
@ -84,8 +84,9 @@ module Sidekiq
end
get "/queues/:name" do
halt 404 unless params[:name]
@name = params[:name]
@messages = Sidekiq.redis.lrange("queue:#{@name}", 0, 10).map { |str| MultiJson.decode(str) }
@messages = Sidekiq.redis {|conn| conn.lrange("queue:#{@name}", 0, 10) }.map { |str| MultiJson.decode(str) }
slim :queue
end
end

View file

@ -1,7 +1,7 @@
PATH
remote: ..
specs:
sidekiq (0.9.0)
sidekiq (0.9.1)
celluloid
connection_pool (>= 0.9.0)
multi_json

View file

@ -47,5 +47,15 @@ class TestWeb < MiniTest::Unit::TestCase
assert_match last_response.body, /foo/
end
it 'handles queues with no name' do
get '/queues'
assert_equal 404, last_response.status
end
it 'handles queue view' do
get '/queues/default'
assert_equal 200, last_response.status
end
end
end

View file

@ -1,6 +1,6 @@
.hero-unit
h1 Sidekiq is #{status}
h1 Sidekiq is #{current_status}
p Processed: #{processed}
p Failed: #{failed}
p Workers: #{workers.size}