LP#1781480: Include group owner ancestor badges
authorMike Rylander <mrylander@gmail.com>
Wed, 19 Sep 2018 14:26:04 +0000 (10:26 -0400)
committerJason Stephenson <jason@sigio.com>
Fri, 21 Sep 2018 14:29:03 +0000 (10:29 -0400)
This commit lightly refactors the badge org logic and includes the ancestors
of location group owners in the list of badge orgs, instead of only the direct
owners.

Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Jeanette Lundgren <jlundgren@cwmars.org>
Signed-off-by: Jason Stephenson <jason@sigio.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/metabib.pm

index 828304f..3ca3751 100644 (file)
@@ -8,6 +8,7 @@ use OpenSRF::Utils::Logger qw/:level/;
 use OpenILS::Application::AppUtils;
 use OpenSRF::Utils::Cache;
 use OpenSRF::Utils::JSON;
 use OpenILS::Application::AppUtils;
 use OpenSRF::Utils::Cache;
 use OpenSRF::Utils::JSON;
+use List::MoreUtils qw(uniq);
 use Data::Dumper;
 use Digest::MD5 qw/md5_hex/;
 
 use Data::Dumper;
 use Digest::MD5 qw/md5_hex/;
 
@@ -3245,9 +3246,9 @@ sub query_parser_fts_wrapper {
                 my $lg_obj = asset::copy_location_group->retrieve($lg);
                 next unless $lg_obj;
     
                 my $lg_obj = asset::copy_location_group->retrieve($lg);
                 next unless $lg_obj;
     
-                push(@borg_list, ''.$lg_obj->owner);
+                push(@borg_list, @{$U->get_org_ancestors(''.$lg_obj->owner)});
             }
             }
-            $borgs = join(',', @borg_list) if @borg_list;
+            $borgs = join(',', uniq @borg_list) if @borg_list;
         }
     
         if (!$borgs) {
         }
     
         if (!$borgs) {
@@ -3265,16 +3266,8 @@ sub query_parser_fts_wrapper {
             }
 
             if ($site) {
             }
 
             if ($site) {
-                $borgs = OpenSRF::AppSession->create( 'open-ils.cstore' )->request(
-                    'open-ils.cstore.json_query.atomic',
-                    { from => [ 'actor.org_unit_ancestors', $site->id ] }
-                )->gather(1);
-
-                if (ref $borgs && @$borgs) {
-                    $borgs = join(',', map { $_->{'id'} } @$borgs);
-                } else {
-                    $borgs = undef;
-                }
+                $borgs = $U->get_org_ancestors($site->id);
+                $borgs = @$borgs ?  join(',', @$borgs) : undef;
             }
         }
     }
             }
         }
     }