From 181c784c8b075a1b3e1dfbd2a3471af2ee843797 Mon Sep 17 00:00:00 2001 From: Lebbeous Fogle-Weekley Date: Fri, 24 Jan 2014 12:24:06 -0500 Subject: [PATCH] LP1272316 - Speed up these settings lookups in the hold targeter that get repeated a ... ... lot when there are lots of copies for a hold. Signed-off-by: Lebbeous Fogle-Weekley Signed-off-by: Mike Rylander Signed-off-by: Chris Sharp Signed-off-by: Ben Shum --- .../Application/Storage/Publisher/action.pm | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm index fe1448dced..449d26279e 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm @@ -9,6 +9,7 @@ use OpenSRF::AppSession; use OpenSRF::EX qw/:try/; use OpenILS::Utils::Fieldmapper; use OpenILS::Utils::PermitHold; +use OpenILS::Utils::CStoreEditor qw/:funcs/; use DateTime; use DateTime::Format::ISO8601; use OpenILS::Utils::Penalty; @@ -58,12 +59,12 @@ sub isTrue { sub ou_ancestor_setting_value_or_cache { # cache should be specific to setting - my ($actor, $org_id, $setting, $cache) = @_; + my ($e, $org_id, $setting, $cache) = @_; if (not exists $cache->{$org_id}) { - my $r = $actor->request( - 'open-ils.actor.ou_setting.ancestor_default', $org_id, $setting - )->gather(1); + my $r = $U->ou_ancestor_setting( + $org_id, $setting, $e # undef $e is ok + ); if ($r) { $cache->{$org_id} = $r->{value}; @@ -1427,6 +1428,7 @@ sub new_hold_copy_targeter { my @successes; my $actor = OpenSRF::AppSession->create('open-ils.actor'); + my $editor = new_editor; my $target_when_closed = {}; my $target_when_closed_if_at_pickup_lib = {}; @@ -1599,7 +1601,7 @@ sub new_hold_copy_targeter { if (''.$hold->pickup_lib eq ''.$c->circ_lib) { $ignore_closing = ou_ancestor_setting_value_or_cache( - $actor, + $editor, ''.$c->circ_lib, 'circ.holds.target_when_closed_if_at_pickup_lib', $target_when_closed_if_at_pickup_lib @@ -1608,7 +1610,7 @@ sub new_hold_copy_targeter { if (not $ignore_closing) { # one more chance to find a reason # to ignore OU closedness. $ignore_closing = ou_ancestor_setting_value_or_cache( - $actor, + $editor, ''.$c->circ_lib, 'circ.holds.target_when_closed', $target_when_closed @@ -1687,9 +1689,9 @@ sub new_hold_copy_targeter { if (!$best) { $log->debug("\tNothing at the pickup lib, looking elsewhere among ".scalar(@$all_copies)." copies"); - $self->{max_loops}{$pu_lib} = $actor->request( - 'open-ils.actor.ou_setting.ancestor_default' => $pu_lib => 'circ.holds.max_org_unit_target_loops' - )->gather(1); + $self->{max_loops}{$pu_lib} = $U->ou_ancestor_setting( + $pu_lib, 'circ.holds.max_org_unit_target_loops', $editor + ); if (defined($self->{max_loops}{$pu_lib})) { $self->{max_loops}{$pu_lib} = $self->{max_loops}{$pu_lib}{value}; @@ -2265,18 +2267,17 @@ sub create_prox_list { my $copies = shift; my $hold = shift; - my $actor = OpenSRF::AppSession->create('open-ils.actor'); - my %prox_list; + my $editor = new_editor; for my $cp (@$copies) { my ($prox) = $self->method_lookup('open-ils.storage.asset.copy.proximity')->run( $cp, $lib, $hold ); next unless (defined($prox)); my $copy_circ_lib = ''.$cp->circ_lib; # Fetch the weighting value for hold targeting, defaulting to 1 - $self->{target_weight}{$copy_circ_lib} ||= $actor->request( - 'open-ils.actor.ou_setting.ancestor_default' => $copy_circ_lib.'' => 'circ.holds.org_unit_target_weight' - )->gather(1); + $self->{target_weight}{$copy_circ_lib} ||= $U->ou_ancestor_setting( + $copy_circ_lib.'', 'circ.holds.org_unit_target_weight', $editor + ); $self->{target_weight}{$copy_circ_lib} = $self->{target_weight}{$copy_circ_lib}{value} if (ref $self->{target_weight}{$copy_circ_lib}); $self->{target_weight}{$copy_circ_lib} ||= 1; -- 2.43.2