From 1e1e83aff5b07fec3f1a5116e15a7a728dc22c2c Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Mon, 30 Apr 2018 17:03:26 -0400 Subject: [PATCH 1/1] LP#14973322: (follow-up) allow profile-only patron searches This patch removes the implicit requirement introduced by the previous patch that a field other than profile be used in the patron search. For performance reasons, it might be good to mark permission.grp_descendants() as stable. Signed-off-by: Galen Charlton Signed-off-by: Jason Boyer Signed-off-by: Mike Rylander --- .../OpenILS/Application/Storage/Publisher/actor.pm | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/actor.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/actor.pm index 134821a110..1cef88bfd6 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/actor.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/actor.pm @@ -775,7 +775,13 @@ sub patron_search { $name = '(' . join(' OR ', @ns) . ')'; } - my $usr_where = join ' AND ', grep { $_ } ($usr,$phone,$ident,$name); + my $profile = ''; + my @profv = (); + if ($prof) { + $profile = '(profile IN (SELECT id FROM permission.grp_descendants(?)))'; + push @profv, $prof; + } + my $usr_where = join ' AND ', grep { $_ } ($usr,$phone,$ident,$name,$profile); my $addr_where = $addr; @@ -821,7 +827,6 @@ sub patron_search { } my $descendants = "actor.org_unit_descendants($search_org)"; - my $profile = "JOIN permission.grp_descendants($prof) p ON (p.id = users.profile)" if $prof; my $opt_in_where = ''; if (lc($strict_opt_in) eq 'true') { @@ -849,7 +854,6 @@ sub patron_search { SELECT $distinct_list FROM $u_table AS users $card JOIN $descendants d ON (d.id = users.home_ou) - $profile $select $clone_select $penalty_join @@ -862,7 +866,7 @@ sub patron_search { OFFSET $offset SQL - return actor::user->db_Main->selectcol_arrayref($select, {Columns=>[scalar(@$sort)]}, map {lc($_)} (@usrv,@phonev,@identv,@namev,@addrv)); + return actor::user->db_Main->selectcol_arrayref($select, {Columns=>[scalar(@$sort)]}, map {lc($_)} (@usrv,@phonev,@identv,@namev,@profv,@addrv)); } __PACKAGE__->register_method( api_name => 'open-ils.storage.actor.user.crazy_search', -- 2.43.2