lib/sidetiq/web.rb in sidetiq-0.4.0.rc2 vs lib/sidetiq/web.rb in sidetiq-0.4.0.rc3

- old
+ new

@@ -4,11 +4,11 @@ module Web VIEWS = File.expand_path('views', File.dirname(__FILE__)) def self.registered(app) app.get "/sidetiq" do - @schedules = Sidetiq.schedules + @workers = Sidetiq.workers @time = Sidetiq.clock.gettime erb File.read(File.join(VIEWS, 'sidetiq.erb')) end app.get "/sidetiq/locks" do @@ -20,38 +20,40 @@ app.get "/sidetiq/:name/schedule" do halt 404 unless (name = params[:name]) @time = Sidetiq.clock.gettime - @worker, @schedule = Sidetiq.schedules.select do |worker, _| + @worker = Sidetiq.workers.detect do |worker| worker.name == name - end.flatten + end + @schedule = @worker.schedule + erb File.read(File.join(VIEWS, 'schedule.erb')) end app.get "/sidetiq/:name/history" do halt 404 unless (name = params[:name]) @time = Sidetiq.clock.gettime - @worker, @schedule = Sidetiq.schedules.select do |worker, _| + @worker = Sidetiq.workers.detect do |worker| worker.name == name - end.flatten + end @history = Sidekiq.redis do |redis| - redis.lrange("sidetiq:#{@worker.name}:history", 0, -1) + redis.lrange("sidetiq:#{name}:history", 0, -1) end erb File.read(File.join(VIEWS, 'history.erb')) end app.post "/sidetiq/:name/trigger" do halt 404 unless (name = params[:name]) - worker, _ = Sidetiq.schedules.select do |w, _| - w.name == name - end.flatten + worker = Sidetiq.workers.detect do |worker| + worker.name == name + end worker.perform_async redirect "#{root_path}sidetiq" end