From 4b825ce3a53d7fceedd4118554c91eaf9e360793 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 Signed-off-by: Jonathan Druart Signed-off-by: Kyle M Hall --- C4/HoldsQueue.pm | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/C4/HoldsQueue.pm b/C4/HoldsQueue.pm index 3774214527..e1ae3c4830 100644 --- a/C4/HoldsQueue.pm +++ b/C4/HoldsQueue.pm @@ -196,9 +196,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(); @@ -781,11 +780,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.39.5