From f3f6e8a4e3f6cebe893c649c1a965009943a38b9 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 22 Feb 2013 15:56:29 +0100 Subject: [PATCH] Search: Don't return hidden projects/jobsets --- src/lib/Hydra/Controller/Root.pm | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/lib/Hydra/Controller/Root.pm b/src/lib/Hydra/Controller/Root.pm index 9b1f1273..2a57dc1a 100644 --- a/src/lib/Hydra/Controller/Root.pm +++ b/src/lib/Hydra/Controller/Root.pm @@ -311,16 +311,27 @@ sub search :Local Args(0) { unless $query =~ /^[a-zA-Z0-9_\-]+$/; $c->stash->{projects} = [ $c->model('DB::Projects')->search( - { -or => [ name => { ilike => "%$query%" }, displayName => { ilike => "%$query%" }, description => { ilike => "%$query%" } ] }, + { -and => + [ { -or => [ name => { ilike => "%$query%" }, displayName => { ilike => "%$query%" }, description => { ilike => "%$query%" } ] } + , { hidden => 0 } + ] + }, { order_by => ["name"] } ) ]; $c->stash->{jobsets} = [ $c->model('DB::Jobsets')->search( - { -or => [ name => { ilike => "%$query%" }, description => { ilike => "%$query%" } ] }, - { order_by => ["project", "name"] } ) ]; + { -and => + [ { -or => [ "me.name" => { ilike => "%$query%" }, "me.description" => { ilike => "%$query%" } ] } + , { "project.hidden" => 0, "me.hidden" => 0 } + ] + }, + { order_by => ["project", "name"], join => ["project"] } ) ]; $c->stash->{jobs} = [ $c->model('DB::Jobs')->search( - { name => { ilike => "%$query%" } }, - { order_by => ["project", "jobset", "name"] } ) ]; + { "me.name" => { ilike => "%$query%" } + , "project.hidden" => 0 + , "jobset.hidden" => 0 + }, + { order_by => ["project", "jobset", "name"], join => ["project", "jobset"] } ) ]; }