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 ed26d4f commit db39945
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 db39945

Please sign in to comment.