hydra-server: add limit parameter to the search path
This allows a client to set a limit to the search results it wants to
get:
http://hydra.nixos.org/search?query=emacs&limit=1
This returns only 1 results (while the default is 500).
This commit is contained in:
@@ -391,7 +391,12 @@ sub search :Local Args(0) {
|
||||
error($c, "Invalid character in query.")
|
||||
unless $query =~ /^[a-zA-Z0-9_\-\/.]+$/;
|
||||
|
||||
$c->stash->{limit} = 500;
|
||||
my $limit = trim $c->request->params->{"limit"};
|
||||
if ($limit eq "") {
|
||||
$c->stash->{limit} = 500;
|
||||
} else {
|
||||
$c->stash->{limit} = $limit;
|
||||
}
|
||||
|
||||
$c->stash->{projects} = [ $c->model('DB::Projects')->search(
|
||||
{ -and =>
|
||||
|
||||
Reference in New Issue
Block a user