From 08dc6650e1d37c215e81eef808581f94d5fb0e99 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 22 Feb 2013 16:41:42 +0100 Subject: [PATCH] Search: Limit the number of results --- src/lib/Hydra/Controller/Root.pm | 3 +++ src/root/search.tt | 2 +- src/root/static/css/hydra.css | 5 +++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/lib/Hydra/Controller/Root.pm b/src/lib/Hydra/Controller/Root.pm index 6c3f3b29..15dcab50 100644 --- a/src/lib/Hydra/Controller/Root.pm +++ b/src/lib/Hydra/Controller/Root.pm @@ -310,6 +310,8 @@ sub search :Local Args(0) { error($c, "Invalid character in query.") unless $query =~ /^[a-zA-Z0-9_\-]+$/; + $c->stash->{limit} = 500; + $c->stash->{projects} = [ $c->model('DB::Projects')->search( { -and => [ { -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"] , "+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"] + , rows => $c->stash->{limit} + 1 } ) ]; } diff --git a/src/root/search.tt b/src/root/search.tt index 7607c2ba..7b67b367 100644 --- a/src/root/search.tt +++ b/src/root/search.tt @@ -43,7 +43,7 @@ [% IF jobs.size > 0; matched = 1 %] -

The following jobs match your query:

+

The following jobs match your query:[% IF jobs.size > limit %] (first [% limit %] results only)[% END %]

diff --git a/src/root/static/css/hydra.css b/src/root/static/css/hydra.css index 5f842feb..a0010b8e 100644 --- a/src/root/static/css/hydra.css +++ b/src/root/static/css/hydra.css @@ -43,3 +43,8 @@ table.info-table th { padding-right: 1.0em; padding-bottom: 0.2em; } + +/* Missing in bootstrap 2.0.2 */ +.text-warning { + color: #c09853; +}