forked from lix-project/hydra
Search: Limit the number of results
This commit is contained in:
parent
4d4ea8c754
commit
08dc6650e1
3 changed files with 9 additions and 1 deletions
|
@ -310,6 +310,8 @@ 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_\-]+$/;
|
||||||
|
|
||||||
|
$c->stash->{limit} = 500;
|
||||||
|
|
||||||
$c->stash->{projects} = [ $c->model('DB::Projects')->search(
|
$c->stash->{projects} = [ $c->model('DB::Projects')->search(
|
||||||
{ -and =>
|
{ -and =>
|
||||||
[ { -or => [ name => { ilike => "%$query%" }, displayName => { ilike => "%$query%" }, description => { ilike => "%$query%" } ] }
|
[ { -or => [ name => { ilike => "%$query%" }, displayName => { ilike => "%$query%" }, description => { ilike => "%$query%" } ] }
|
||||||
|
@ -334,6 +336,7 @@ sub search :Local Args(0) {
|
||||||
{ order_by => ["enabled_ desc", "project", "jobset", "name"], join => ["project", "jobset"]
|
{ order_by => ["enabled_ desc", "project", "jobset", "name"], join => ["project", "jobset"]
|
||||||
, "+select" => [\ "(project.enabled = 1 and jobset.enabled = 1 and exists (select 1 from Builds where project = project.name and jobset = jobset.name and job = me.name and iscurrent = 1)) enabled_"]
|
, "+select" => [\ "(project.enabled = 1 and jobset.enabled = 1 and exists (select 1 from Builds where project = project.name and jobset = jobset.name and job = me.name and iscurrent = 1)) enabled_"]
|
||||||
, "+as" => ["enabled"]
|
, "+as" => ["enabled"]
|
||||||
|
, rows => $c->stash->{limit} + 1
|
||||||
} ) ];
|
} ) ];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
|
|
||||||
[% IF jobs.size > 0; matched = 1 %]
|
[% IF jobs.size > 0; matched = 1 %]
|
||||||
|
|
||||||
<p>The following jobs match your query:</p>
|
<p>The following jobs match your query:[% IF jobs.size > limit %] <span class="text-warning">(first [% limit %] results only)</span>[% END %]</p>
|
||||||
|
|
||||||
<table class="table table-striped table-condensed">
|
<table class="table table-striped table-condensed">
|
||||||
<thead>
|
<thead>
|
||||||
|
|
|
@ -43,3 +43,8 @@ table.info-table th {
|
||||||
padding-right: 1.0em;
|
padding-right: 1.0em;
|
||||||
padding-bottom: 0.2em;
|
padding-bottom: 0.2em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Missing in bootstrap 2.0.2 */
|
||||||
|
.text-warning {
|
||||||
|
color: #c09853;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue