[open-ils-commits] [GIT] Evergreen ILS branch master updated. 1e1e83aff5b07fec3f1a5116e15a7a728dc22c2c

Evergreen Git git at git.evergreen-ils.org
Tue May 22 15:55:05 EDT 2018


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, master has been updated
       via  1e1e83aff5b07fec3f1a5116e15a7a728dc22c2c (commit)
       via  ce419b57e2d8b3091d9703261a106f74000a3ba9 (commit)
       via  28f155fe7a0def347e6b01a59d94d4780f766410 (commit)
      from  0f4113a1ca958431acc0937e87b801aed3ddae1c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 1e1e83aff5b07fec3f1a5116e15a7a728dc22c2c
Author: Galen Charlton <gmc at equinoxinitiative.org>
Date:   Mon Apr 30 17:03:26 2018 -0400

    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 <gmc at equinoxinitiative.org>
    Signed-off-by: Jason Boyer <jboyer at library.in.gov>
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

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 134821a..1cef88b 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, at phonev, at identv, at namev, at addrv));
+    return actor::user->db_Main->selectcol_arrayref($select, {Columns=>[scalar(@$sort)]}, map {lc($_)} (@usrv, at phonev, at identv, at namev, at profv, at addrv));
 }
 __PACKAGE__->register_method(
     api_name    => 'open-ils.storage.actor.user.crazy_search',

commit ce419b57e2d8b3091d9703261a106f74000a3ba9
Author: Jason Boyer <jboyer at library.in.gov>
Date:   Fri Apr 20 14:49:25 2018 -0400

    LP14973322: Search for Users by Profile
    
    Stop treating profile like a text value, instead
    include users in the selected profiles and descendants.
    
    To test
    -------
    [0] Search for users by last name (and / or first) and do not
        select a profile, take note of results
    [1] Select the top of your permission group tree (Users, likely) and
        search again, results should be the same.
    [2] Select a group further down the tree (Circulators, Administrators,
        Patrons, etc.) and repeat the search, there should only be results
        from that group and its descendants.
    [3] Finally, select a group with no child groups. Results will only be
        that specific group.
    
    Signed-off-by: Jason Boyer <jboyer at library.in.gov>
    Signed-off-by: Terran McCanna <tmccanna at georgialibraries.org>
    Signed-off-by: Galen Charlton <gmc at equinoxinitiative.org>
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

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 a1e634d..134821a 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
@@ -677,6 +677,7 @@ sub patron_search {
     # group 2 = phone, ident
     # group 3 = barcode
     # group 4 = dob
+    # group 5 = profile
 
     # Treatment of name fields depends on whether the org has 
     # diacritic_insensitivity turned on or off.
@@ -718,6 +719,10 @@ sub patron_search {
     my $addr = join ' AND ', map { "evergreen.lowercase(CAST($_ AS text)) ~ ?" } grep { ''.$$search{$_}{group} eq '1' } keys %$search;
     my @addrv = map { "^" . _clean_regex_chars($$search{$_}{value}) } grep { ''.$$search{$_}{group} eq '1' } keys %$search;
 
+    # should only be 1 profile sent but this construction makes dealing with the lists simpler.
+    my ($prof) = map { $$search{$_}{value} } grep {''.$$search{$_}{group} eq '5' } keys %$search;
+    $prof = int($prof) if $prof; # int or out
+
     my $pv = _clean_regex_chars($$search{phone}{value});
     my $iv = _clean_regex_chars($$search{ident}{value});
     my $nv = _clean_regex_chars($$search{name}{value});
@@ -816,6 +821,7 @@ 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') {
@@ -843,6 +849,7 @@ 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
diff --git a/Open-ILS/web/js/ui/default/staff/services/patron_search.js b/Open-ILS/web/js/ui/default/staff/services/patron_search.js
index f19678f..b0f1bed 100644
--- a/Open-ILS/web/js/ui/default/staff/services/patron_search.js
+++ b/Open-ILS/web/js/ui/default/staff/services/patron_search.js
@@ -775,7 +775,7 @@ function($scope,  $q,  $routeParams,  $timeout,  $window,  $location,  egCore,
         angular.forEach(args, function(val, key) {
             if (!val) return;
             if (key == 'profile' && args.profile) {
-                search.profile = {value : args.profile.id(), group : 0};
+                search.profile = {value : args.profile.id(), group : 5};
             } else if (key == 'home_ou' && args.home_ou) {
                 search.home_ou = args.home_ou.id(); // passed separately
             } else if (key == 'inactive') {

commit 28f155fe7a0def347e6b01a59d94d4780f766410
Author: Galen Charlton <gmc at equinoxinitiative.org>
Date:   Mon Apr 30 16:14:52 2018 -0400

    LP#1497322: add Perl live_t regression and unit tests for patron searching
    
    Signed-off-by: Galen Charlton <gmc at equinoxinitiative.org>
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

diff --git a/Open-ILS/src/perlmods/live_t/27-lp1497322-patron-search-by-profile.t b/Open-ILS/src/perlmods/live_t/27-lp1497322-patron-search-by-profile.t
new file mode 100644
index 0000000..b07fa5b
--- /dev/null
+++ b/Open-ILS/src/perlmods/live_t/27-lp1497322-patron-search-by-profile.t
@@ -0,0 +1,62 @@
+#!perl
+use strict; use warnings;
+
+use Test::More tests => 4;
+
+diag("Tests searching for patrons by profile");
+
+use DateTime;
+use OpenILS::Utils::TestUtils;
+my $script = OpenILS::Utils::TestUtils->new();
+our $apputils = 'OpenILS::Application::AppUtils';
+$script->bootstrap;
+
+$script->authenticate({
+    username => 'admin',
+    password => 'demo123',
+    type => 'staff'
+});
+
+ok($script->authtoken, 'Have an authtoken');
+
+my $results = $apputils->simplereq(
+    'open-ils.actor',
+    'open-ils.actor.patron.search.advanced.fleshed.atomic',
+    $script->authtoken,
+    {"family_name" => {"value" => "smith", "group" =>  0}},
+    10,
+    [],
+    undef,
+    1,
+    ["cards"]
+);
+
+cmp_ok(@$results, '>=', 1, 'Patron search on "Smith" returns at least one result');
+
+$results = $apputils->simplereq(
+    'open-ils.actor',
+    'open-ils.actor.patron.search.advanced.fleshed.atomic',
+    $script->authtoken,
+    {"profile" => {"value" => 3, "group" =>  0}},
+    10,
+    [],
+    undef,
+    1,
+    ["cards"]
+);
+
+cmp_ok(@$results, '==', 0, 'Patron search profile 3 (staff) in group 0 returns at zero results');
+
+$results = $apputils->simplereq(
+    'open-ils.actor',
+    'open-ils.actor.patron.search.advanced.fleshed.atomic',
+    $script->authtoken,
+    {"profile" => {"value" => 3, "group" =>  5}},
+    10,
+    [],
+    undef,
+    1,
+    ["cards"]
+);
+
+cmp_ok(@$results, '>=', 1, 'Patron search profile 3 (staff) in group 5 returns at least one result');

-----------------------------------------------------------------------

Summary of changes:
 .../OpenILS/Application/Storage/Publisher/actor.pm |   15 ++++-
 .../live_t/27-lp1497322-patron-search-by-profile.t |   62 ++++++++++++++++++++
 .../js/ui/default/staff/services/patron_search.js  |    2 +-
 3 files changed, 76 insertions(+), 3 deletions(-)
 create mode 100644 Open-ILS/src/perlmods/live_t/27-lp1497322-patron-search-by-profile.t


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list