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 <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Kyle Hall 2021-06-03 06:44:59 -04:00 committed by Jonathan Druart
parent 9588776bac
commit b7ae33b47b

View file

@ -193,9 +193,8 @@ sub CreateQueue {
undef $transport_cost_matrix; 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(); my $bibs_with_pending_requests = GetBibsWithPendingHoldRequests();
@ -778,11 +777,15 @@ sub _trim {
} }
sub load_branches_to_pull_from { sub load_branches_to_pull_from {
my $use_transport_cost_matrix = shift;
my @branches_to_use; my @branches_to_use;
my $static_branch_list = C4::Context->preference("StaticHoldsQueueWeight"); unless ( $use_transport_cost_matrix ) {
@branches_to_use = map { _trim($_) } split( /,/, $static_branch_list ) my $static_branch_list = C4::Context->preference("StaticHoldsQueueWeight");
if $static_branch_list; @branches_to_use = map { _trim($_) } split( /,/, $static_branch_list )
if $static_branch_list;
}
@branches_to_use = @branches_to_use =
Koha::Database->new()->schema()->resultset('Branch') Koha::Database->new()->schema()->resultset('Branch')