From: Mike Rylander Date: Wed, 19 Sep 2018 14:26:04 +0000 (-0400) Subject: LP#1781480: Include group owner ancestor badges X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=437e7f826a9a36be2db65f96ad6862c9bea1094d;p=evergreen%2Ftadl.git LP#1781480: Include group owner ancestor badges 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 Signed-off-by: Jeanette Lundgren Signed-off-by: Jason Stephenson --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/metabib.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/metabib.pm index 828304f407..3ca3751f1f 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/metabib.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/metabib.pm @@ -8,6 +8,7 @@ use OpenSRF::Utils::Logger qw/:level/; 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/; @@ -3245,9 +3246,9 @@ sub query_parser_fts_wrapper { 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) { @@ -3265,16 +3266,8 @@ sub query_parser_fts_wrapper { } 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; } } }