Skip to content
This repository has been archived by the owner on Jun 4, 2021. It is now read-only.

Commit

Permalink
Add pagination to commands collection
Browse files Browse the repository at this point in the history
The commands collection, which can grow quite lengthy, currently does not
allow any pagination. This provides the "start" and "limit" query arguments,
which are present for many other collections.
  • Loading branch information
Scott McClellan committed Dec 12, 2015
1 parent 05f2c1a commit 30724bd
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ def render_template(name)
# hand-coded list, but ... it will do, for now.
COLLECTIONS = [:brokers, :repos, :tags, :policies,
[:nodes, {'start' => {"type" => "number"}, 'limit' => {"type" => "number"}}],
:tasks, :commands,
:tasks, [:commands, {'start' => {'type' => 'number'}, 'limit' => {'type' => 'number'}}],
[:events, {'start' => {"type" => "number"}, 'limit' => {"type" => "number"}}], :hooks]

#
Expand Down Expand Up @@ -703,6 +703,8 @@ def paginate(start, limit)
end

get '/api/collections/commands' do
start, limit = paginate(params[:start], params[:limit])

collection_view Razor::Data::Command.order(:submitted_at).order(:id),
'commands', limit: limit, start: start, facts: true
end
Expand Down

0 comments on commit 30724bd

Please sign in to comment.