From 3b70d0a5c40e0414faf7edf032f3d82a3b033208 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Thu, 3 Jun 2021 06:44:59 -0400 Subject: [PATCH] Bug 28510: Skip processing holds queue items from closed libraries when HoldsQueueSkipClosed is enabled Right now we skip closed branch's items as we iterate over all items looking for ones to fill a hold. If HoldsQueueSkipClosed is enabled, no items held be a closed library can be targeted, so it would be more efficient if we never selected the items from those branches to begin with. This is how the holds queue works if we are not using the transport cost matrix, so we should make it work the same way if we *are* using the matrix. Test Plan: 1) Apply this patch 2) prove prove t/db_dependent/HoldsQueue.t 3) All tests should continue to pass Signed-off-by: David Nind Signed-off-by: Martin Renvoize --- C4/HoldsQueue.pm | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/C4/HoldsQueue.pm b/C4/HoldsQueue.pm index 06b0b2a2efa..f5743ceddf6 100644 --- a/C4/HoldsQueue.pm +++ b/C4/HoldsQueue.pm @@ -193,9 +193,8 @@ sub CreateQueue { undef $transport_cost_matrix; } } - unless ($transport_cost_matrix) { - $branches_to_use = load_branches_to_pull_from(); - } + + $branches_to_use = load_branches_to_pull_from($use_transport_cost_matrix); my $bibs_with_pending_requests = GetBibsWithPendingHoldRequests(); @@ -778,11 +777,15 @@ sub _trim { } sub load_branches_to_pull_from { + my $use_transport_cost_matrix = shift; + my @branches_to_use; - my $static_branch_list = C4::Context->preference("StaticHoldsQueueWeight"); - @branches_to_use = map { _trim($_) } split( /,/, $static_branch_list ) - if $static_branch_list; + unless ( $use_transport_cost_matrix ) { + my $static_branch_list = C4::Context->preference("StaticHoldsQueueWeight"); + @branches_to_use = map { _trim($_) } split( /,/, $static_branch_list ) + if $static_branch_list; + } @branches_to_use = Koha::Database->new()->schema()->resultset('Branch') -- 2.20.1