Skip to content

Commit

Permalink
Release v6.0.7_patched
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
jatin-apolloio committed Sep 21, 2022
1 parent e3c5551 commit 6d7e848
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 16 deletions.
19 changes: 14 additions & 5 deletions lib/sidekiq/web/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 5 additions & 1 deletion web/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ en: # <---- change this to your locale code
Delete: Delete
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?
AreYouSureDeleteQueue: Are you sure you want to delete the %{queue} queue? This will delete all jobs within the queue, it will reappear if you push more jobs to it in the future.
AreYouSureNonWorkHourQueue: Are you sure? This will pause the %{queue} queue and will execute the jobs only during non-work hours!
AreYouSureUnpauseNonWorkHourQueue: "Running an intensive job during work-hours may have real production consequence on performance. It is not uncommon for such jobs to hammer our database and slow down the website. Please seek approval from Ray or the #squad-platform before you do this."
Queues: Queues
Size: Size
Actions: Actions
Expand Down Expand Up @@ -81,3 +83,5 @@ en: # <---- change this to your locale code
Latency: Latency
Pause: Pause
Unpause: Unpause
StartExecution: Run all hours
PauseTillNonWorkHours: Run non-work hours
39 changes: 29 additions & 10 deletions web/views/queues.erb
Original file line number Diff line number Diff line change
@@ -1,35 +1,54 @@
<h3><%= t('Queues') %></h3>

<div class="table_container">
<style>
.btn-warning {
color: #fff !important;
background-color: #cc8015 !important;
border-color: #eea236 !important;
background-image: none !important;
}

.label-warning {
background-color: #cc8015 !important;
}
</style>
<table class="queues table table-hover table-bordered table-striped table-white">
<thead>
<th><%= t('Queue') %></th>
<th><%= t('Size') %></th>
<th><%= t('Latency') %></th>
<th><%= t('Actions') %></th>
<th class="col-md-3"><%= t('Actions') %></th>
</thead>
<% @queues.each do |queue| %>
<tr>
<td>
<a href="<%= root_path %>queues/<%= CGI.escape(queue.name) %>"><%= h queue.name %></a>
<% if queue.paused? %>
<span class="label label-danger"><%= t('Paused') %></span>
<span class="label label-warning"><%= t('Paused') %></span>
<% end %>
<% if queue.is_non_work_hour_only? %>
<span class="label label-danger">Non-work hours only</span>
<% end %>
</td>
<td><%= number_with_delimiter(queue.size) %> </td>
<td><% queue_latency = queue.latency %><%= number_with_delimiter(queue_latency.round(2)) %><%= (queue_latency < 60) ? '' : " (#{relative_time(Time.at(Time.now.to_f - queue_latency))})" %> </td>
<td>
<% queue_latency = queue.latency %><%= number_with_delimiter(queue_latency.round(2)) %><%= (queue_latency < 60) ? '' : " (#{relative_time(Time.at(Time.now.to_f - queue_latency))})" %> </td>
<td class="delete-confirm">
<form action="<%=root_path %>queues/<%= CGI.escape(queue.name) %>" method="post">
<form action="<%= root_path %>queues/<%= CGI.escape(queue.name) %>" method="post">
<%= csrf_tag %>
<input class="btn btn-danger btn-xs" type="submit" name="delete" value="<%= t('Delete') %>" data-confirm="<%= t('AreYouSureDeleteQueue', :queue => h(queue.name)) %>" />

<% if Sidekiq.pro? %>
<% if queue.is_non_work_hour_only? %>
<input class="btn btn-danger btn-xs" type="submit" name="unset_non_work_hour" value="<%= t('StartExecution') %>" data-confirm="<%= t('AreYouSureUnpauseNonWorkHourQueue', :queue => h(queue.name)) %>"/>
<% else %>
<input class="btn btn-danger btn-xs" type="submit" name="set_non_work_hour" value="<%= t('PauseTillNonWorkHours') %>" data-confirm="<%= t('AreYouSureNonWorkHourQueue', :queue => h(queue.name)) %>"/>
<% end %>
<% unless queue.is_non_work_hour_only? %>
<% if queue.paused? %>
<input class="btn btn-danger btn-xs" type="submit" name="unpause" value="<%= t('Unpause') %>" />
<input class="btn btn-warning btn-xs" type="submit" name="unpause" value="<%= t('Unpause') %>"/>
<% else %>
<input class="btn btn-danger btn-xs" type="submit" name="pause" value="<%= t('Pause') %>" />
<input class="btn btn-warning btn-xs" type="submit" name="pause" value="<%= t('Pause') %>"/>
<% end %>
<% end %>
<input class="btn btn-danger btn-xs" type="submit" name="delete" value="<%= t('Delete') %>" data-confirm="<%= t('AreYouSureDeleteQueue', :queue => h(queue.name)) %>"/>
</form>
</td>
</tr>
Expand Down

0 comments on commit 6d7e848

Please sign in to comment.