Merge pull request #656 from nlewo/search-limit-param

hydra-server: add limit parameter on search path
This commit is contained in:
Eelco Dolstra 2019-06-19 16:45:51 +02:00 committed by GitHub
commit c85bf668e6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -391,7 +391,12 @@ sub search :Local Args(0) {
error($c, "Invalid character in query.")
unless $query =~ /^[a-zA-Z0-9_\-\/.]+$/;
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 =>
@ -423,11 +428,15 @@ sub search :Local Args(0) {
# Perform build search in separate queries to prevent seq scan on buildoutputs table.
$c->stash->{builds} = [ $c->model('DB::Builds')->search(
{ "buildoutputs.path" => { ilike => "%$query%" } },
{ order_by => ["id desc"], join => ["buildoutputs"] } ) ];
{ order_by => ["id desc"], join => ["buildoutputs"]
, rows => $c->stash->{limit}
} ) ];
$c->stash->{buildsdrv} = [ $c->model('DB::Builds')->search(
{ "drvpath" => { ilike => "%$query%" } },
{ order_by => ["id desc"] } ) ];
{ order_by => ["id desc"]
, rows => $c->stash->{limit}
} ) ];
$c->stash->{resource} = { projects => $c->stash->{projects},
jobsets => $c->stash->{jobsets},