Skip to content

Commit

Permalink
Move "per page" value to a const
Browse files Browse the repository at this point in the history
  • Loading branch information
kiela committed Dec 29, 2014
1 parent 7f72d11 commit 83da351
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/resque/server/views/statuses.erb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
</table>

<% unless @statuses.empty? %>
<%= partial :next_more, :start => @start, :size => @size, :per_page => 50 %>
<%= partial :next_more, :start => @start, :size => @size, :per_page => per_page %>
<% end %>
<%= status_poll(@start) %>
Expand Down
9 changes: 7 additions & 2 deletions lib/resque/status_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ module Resque
module StatusServer

VIEW_PATH = File.join(File.dirname(__FILE__), 'server', 'views')
PER_PAGE = 50

def self.registered(app)

app.get '/statuses' do
@start = params[:start].to_i
@end = @start + (params[:per_page] || 50) - 1
@end = @start + (params[:per_page] || per_page) - 1
@statuses = Resque::Plugins::Status::Hash.statuses(@start, @end)
@size = Resque::Plugins::Status::Hash.count
status_view(:statuses)
Expand Down Expand Up @@ -52,13 +53,17 @@ def self.registered(app)
@polling = true

@start = params[:start].to_i
@end = @start + (params[:per_page] || 50) - 1
@end = @start + (params[:per_page] || per_page) - 1
@statuses = Resque::Plugins::Status::Hash.statuses(@start, @end)
@size = Resque::Plugins::Status::Hash.count
status_view(:statuses, {:layout => false})
end

app.helpers do
def per_page
PER_PAGE
end

def status_view(filename, options = {}, locals = {})
erb(File.read(File.join(::Resque::StatusServer::VIEW_PATH, "#{filename}.erb")), options, locals)
end
Expand Down

0 comments on commit 83da351

Please sign in to comment.