forked from lix-project/hydra
Merge pull request #656 from nlewo/search-limit-param
hydra-server: add limit parameter on search path
This commit is contained in:
commit
c85bf668e6
|
@ -391,7 +391,12 @@ sub search :Local Args(0) {
|
||||||
error($c, "Invalid character in query.")
|
error($c, "Invalid character in query.")
|
||||||
unless $query =~ /^[a-zA-Z0-9_\-\/.]+$/;
|
unless $query =~ /^[a-zA-Z0-9_\-\/.]+$/;
|
||||||
|
|
||||||
|
my $limit = trim $c->request->params->{"limit"};
|
||||||
|
if ($limit eq "") {
|
||||||
$c->stash->{limit} = 500;
|
$c->stash->{limit} = 500;
|
||||||
|
} else {
|
||||||
|
$c->stash->{limit} = $limit;
|
||||||
|
}
|
||||||
|
|
||||||
$c->stash->{projects} = [ $c->model('DB::Projects')->search(
|
$c->stash->{projects} = [ $c->model('DB::Projects')->search(
|
||||||
{ -and =>
|
{ -and =>
|
||||||
|
@ -423,11 +428,15 @@ sub search :Local Args(0) {
|
||||||
# Perform build search in separate queries to prevent seq scan on buildoutputs table.
|
# Perform build search in separate queries to prevent seq scan on buildoutputs table.
|
||||||
$c->stash->{builds} = [ $c->model('DB::Builds')->search(
|
$c->stash->{builds} = [ $c->model('DB::Builds')->search(
|
||||||
{ "buildoutputs.path" => { ilike => "%$query%" } },
|
{ "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(
|
$c->stash->{buildsdrv} = [ $c->model('DB::Builds')->search(
|
||||||
{ "drvpath" => { ilike => "%$query%" } },
|
{ "drvpath" => { ilike => "%$query%" } },
|
||||||
{ order_by => ["id desc"] } ) ];
|
{ order_by => ["id desc"]
|
||||||
|
, rows => $c->stash->{limit}
|
||||||
|
} ) ];
|
||||||
|
|
||||||
$c->stash->{resource} = { projects => $c->stash->{projects},
|
$c->stash->{resource} = { projects => $c->stash->{projects},
|
||||||
jobsets => $c->stash->{jobsets},
|
jobsets => $c->stash->{jobsets},
|
||||||
|
|
Loading…
Reference in a new issue