Skip to content

Commit

Permalink
Add pagination to "Busy" page (#5556)
Browse files Browse the repository at this point in the history
  • Loading branch information
fatkodima committed Oct 3, 2022
1 parent 657f085 commit d424e45
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
8 changes: 8 additions & 0 deletions lib/sidekiq/paginator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,13 @@ def page(key, pageidx = 1, page_size = 25, opts = nil)
end
end
end

def page_items(items, pageidx = 1, page_size = 25)
current_page = pageidx.to_i < 1 ? 1 : pageidx.to_i
pageidx = current_page - 1
starting = pageidx * page_size
items = items.to_a
[current_page, items.size, items[starting, page_size]]
end
end
end
3 changes: 3 additions & 0 deletions lib/sidekiq/web/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ def self.set(key, val)
end

get "/busy" do
@count = (params["count"] || 100).to_i
(@current_page, @total_size, @workset) = page_items(workset, params["page"], @count)

erb(:busy)
end

Expand Down
7 changes: 6 additions & 1 deletion web/views/busy.erb
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@
<div class="col-sm-7">
<h3><%= t('Jobs') %></h3>
</div>
<% if @workset.size > 0 && @total_size > @count %>
<div class="col-sm-4">
<%= erb :_paging, locals: { url: "#{root_path}busy" } %>
</div>
<% end %>
</div>

<div class="table_container">
Expand All @@ -109,7 +114,7 @@
<th><%= t('Arguments') %></th>
<th><%= t('Started') %></th>
</thead>
<% workset.each do |process, thread, msg| %>
<% @workset.each do |process, thread, msg| %>
<% job = Sidekiq::JobRecord.new(msg['payload']) %>
<tr>
<td><%= process %></td>
Expand Down

0 comments on commit d424e45

Please sign in to comment.