From 833232c88cb4521709c572fdffdc0b546481c163 Mon Sep 17 00:00:00 2001 From: Jatin K Malik Date: Thu, 15 Sep 2022 14:43:44 +0530 Subject: [PATCH] Release v6.0.7_patched - Updated Queues.erb to show queue state - non work hours only - Updated Locales to include new buttons - Updated API path for queue post call for new actions --- lib/sidekiq/web/application.rb | 19 +++++++++++----- web/locales/en.yml | 3 +++ web/views/queues.erb | 41 +++++++++++++++++++++++++--------- 3 files changed, 48 insertions(+), 15 deletions(-) diff --git a/lib/sidekiq/web/application.rb b/lib/sidekiq/web/application.rb index da787dce99..9e41d6b8ab 100644 --- a/lib/sidekiq/web/application.rb +++ b/lib/sidekiq/web/application.rb @@ -88,15 +88,24 @@ def self.set(key, val) erb(:queue) end - - post "/queues/:name" do + + post '/queues/:name' do queue = Sidekiq::Queue.new(route_params[:name]) - if Sidekiq.pro? && params["pause"] + unless Sidekiq.pro? + queue.clear + redirect "#{root_path}queues" + end + + if params['pause'] queue.pause! - elsif Sidekiq.pro? && params["unpause"] + elsif params['unpause'] queue.unpause! - else + elsif params['set_non_work_hour'] + queue.set_non_work_hour_only! + elsif params['unset_non_work_hour'] + queue.unset_non_work_hour_only! + elsif params['delete'] queue.clear end diff --git a/web/locales/en.yml b/web/locales/en.yml index 161968e897..cc4c9ac4c1 100644 --- a/web/locales/en.yml +++ b/web/locales/en.yml @@ -27,6 +27,9 @@ en: # <---- change this to your locale code AddToQueue: Add to queue AreYouSureDeleteJob: Are you sure you want to delete this job? AreYouSureDeleteQueue: Are you sure you want to delete the %{queue} queue? + AreYouSureNonWorkHourQueue: Are you sure? This will pause the queue - %{queue} and will auto resume during non-work hours! + AreYouSureUnpauseNonWorkHourQueue: Are you sure? This will unpause the queue - %{queue} and will start executing immediately! + DeleteQueueTooltip: This will delete all jobs within the queue, it will reappear if you push more jobs to it in the future. Queues: Queues Size: Size Actions: Actions diff --git a/web/views/queues.erb b/web/views/queues.erb index f4dde49d25..c2b0fe2243 100644 --- a/web/views/queues.erb +++ b/web/views/queues.erb @@ -1,12 +1,25 @@

<%= t('Queues') %>

-
- + +
- + <% @queues.each do |queue| %> @@ -15,21 +28,29 @@ <% if queue.paused? %> <%= t('Paused') %> <% end %> + <% if queue.is_non_work_hour_only? %> + Non Work Hours Only + <% end %> - +
<%= t('Queue') %> <%= t('Size') %> <%= t('Latency') %><%= t('Actions') %><%= t('Actions') %>
<%= number_with_delimiter(queue.size) %> <% queue_latency = queue.latency %><%= number_with_delimiter(queue_latency.round(2)) %><%= (queue_latency < 60) ? '' : " (#{relative_time(Time.at(Time.now.to_f - queue_latency))})" %> + <% queue_latency = queue.latency %><%= number_with_delimiter(queue_latency.round(2)) %><%= (queue_latency < 60) ? '' : " (#{relative_time(Time.at(Time.now.to_f - queue_latency))})" %> -
+ <%= csrf_tag %> - - - <% if Sidekiq.pro? %> + <% if queue.is_non_work_hour_only? %> + + <% else %> + + <% end %> + <% unless queue.is_non_work_hour_only? %> <% if queue.paused? %> - + <% else %> - + <% end %> <% end %> +