lib/sidekiq/expected_failures/web.rb in sidekiq-expected_failures-0.3.0 vs lib/sidekiq/expected_failures/web.rb in sidekiq-expected_failures-0.4.0

- old
+ new

@@ -1,17 +1,20 @@ module Sidekiq module ExpectedFailures module Web - def self.registered(app) web_dir = File.expand_path("../../../../web", __FILE__) app.helpers do def link_to_details(job) data = [] - job["args"].each_with_index { |argument, index| data << "data-#{index+1}='#{h argument.inspect}'" } - "<a href='#' #{data.join(' ')} title='#{job["worker"]}'>Details</a>" + search = "" + job["args"].each_with_index do |argument, index| + data << "data-#{index+1}='#{h argument.inspect}'" + search << h(argument.inspect) + end + "<a href='#' data-search='#{search.downcase}' #{data.join(' ')} title='#{job["worker"]}'>Details</a>" end end app.post "/expected_failures/clear" do if %w(old all counters).include?(params[:what]) @@ -23,11 +26,11 @@ app.get "/expected_failures/stats" do json(failures: Sidekiq::ExpectedFailures.counters) end - app.get "/expected_failures" do + panel = proc do @dates = Sidekiq::ExpectedFailures.dates @count = (params[:count] || 50).to_i if @dates @date = params[:date] || @dates.keys[0] @@ -39,9 +42,17 @@ @javascript = %w(expected bootstrap).map do |file| File.read(File.join(web_dir, "assets/#{file}.js")) end.join erb File.read(File.join(web_dir, "views/expected_failures.erb")) + end + + app.get "/expected_failures/day/:date" do + self.instance_exec(&panel) + end + + app.get "/expected_failures" do + self.instance_exec(&panel) end end end end end