From d724875c4a7d49d06182e3f7e121275344476410 Mon Sep 17 00:00:00 2001 From: Aaron Ackerman Date: Fri, 25 Oct 2013 20:52:59 -0500 Subject: [PATCH] Allow polling and paging parameters to work together in Sidekiq web ui --- lib/sidekiq/web_helpers.rb | 12 +++++++++++- web/views/_paging.erb | 10 +++++----- web/views/_poll.erb | 2 +- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/lib/sidekiq/web_helpers.rb b/lib/sidekiq/web_helpers.rb index 4fd3440f..6200ea88 100644 --- a/lib/sidekiq/web_helpers.rb +++ b/lib/sidekiq/web_helpers.rb @@ -76,7 +76,7 @@ module Sidekiq def location Sidekiq.redis { |conn| conn.client.location } end - + def redis_connection Sidekiq.redis { |conn| conn.client.id } end @@ -110,6 +110,16 @@ module Sidekiq [score.to_f, jid] end + SAFE_QPARAMS = %w(page poll) + + # Merge options with current params, filter safe params, and stringify to query string + def qparams(options) + options = options.stringify_keys + params.merge(options).map { |key, value| + SAFE_QPARAMS.include?(key) ? "#{key}=#{value}" : next + }.join("&") + end + def truncate(text, truncate_after_chars = 2000) truncate_after_chars && text.size > truncate_after_chars ? "#{text[0..truncate_after_chars]}..." : text end diff --git a/web/views/_paging.erb b/web/views/_paging.erb index c93dffef..8b759286 100644 --- a/web/views/_paging.erb +++ b/web/views/_paging.erb @@ -1,23 +1,23 @@ <% if @total_size > @count %> <% end %> diff --git a/web/views/_poll.erb b/web/views/_poll.erb index 0c8a60d8..b3ba167f 100644 --- a/web/views/_poll.erb +++ b/web/views/_poll.erb @@ -7,6 +7,6 @@ <% if params[:poll] %> <%= t('StopPolling') %> <% else %> - <%= t('LivePoll') %> + <%= t('LivePoll') %> <% end %> <% end %>