Lines 931-938
are allowed to be passed to avoid calculating them many times inside loops.
Link Here
|
931 |
|
931 |
|
932 |
sub update_queue_for_biblio { |
932 |
sub update_queue_for_biblio { |
933 |
my ($args) = @_; |
933 |
my ($args) = @_; |
934 |
|
|
|
935 |
my $biblio_id = $args->{biblio_id}; |
934 |
my $biblio_id = $args->{biblio_id}; |
|
|
935 |
my $result; |
936 |
|
937 |
# FIXME This option is always set, is there ever a case where we want to update the queue, but not empty it? |
938 |
if ( $args->{delete} ) { |
939 |
my $dbh = C4::Context->dbh; |
940 |
|
941 |
$dbh->do("DELETE FROM tmp_holdsqueue WHERE biblionumber=$biblio_id"); |
942 |
$dbh->do("DELETE FROM hold_fill_targets WHERE biblionumber=$biblio_id"); |
943 |
} |
944 |
|
945 |
my $hold_requests = GetPendingHoldRequestsForBib($biblio_id); |
946 |
$result->{requests} = scalar( @{$hold_requests} ); |
947 |
# No need to check anything else if there are no holds to fill |
948 |
return $result unless $result->{requests}; |
936 |
|
949 |
|
937 |
my $branches_to_use = $args->{branches_to_use} // load_branches_to_pull_from( C4::Context->preference('UseTransportCostMatrix') ); |
950 |
my $branches_to_use = $args->{branches_to_use} // load_branches_to_pull_from( C4::Context->preference('UseTransportCostMatrix') ); |
938 |
my $transport_cost_matrix; |
951 |
my $transport_cost_matrix; |
Lines 944-963
sub update_queue_for_biblio {
Link Here
|
944 |
$transport_cost_matrix = $args->{transport_cost_matrix}; |
957 |
$transport_cost_matrix = $args->{transport_cost_matrix}; |
945 |
} |
958 |
} |
946 |
|
959 |
|
947 |
if ( $args->{delete} ) { |
|
|
948 |
my $dbh = C4::Context->dbh; |
949 |
|
950 |
$dbh->do("DELETE FROM tmp_holdsqueue WHERE biblionumber=$biblio_id"); |
951 |
$dbh->do("DELETE FROM hold_fill_targets WHERE biblionumber=$biblio_id"); |
952 |
} |
953 |
|
954 |
my $hold_requests = GetPendingHoldRequestsForBib($biblio_id); |
955 |
my $available_items = GetItemsAvailableToFillHoldRequestsForBib( $biblio_id, $branches_to_use ); |
960 |
my $available_items = GetItemsAvailableToFillHoldRequestsForBib( $biblio_id, $branches_to_use ); |
956 |
|
961 |
|
957 |
my $result = { |
962 |
$result->{available_items} = scalar( @{$available_items} ); |
958 |
requests => scalar( @{$hold_requests} ), |
|
|
959 |
available_items => scalar( @{$available_items} ), |
960 |
}; |
961 |
|
963 |
|
962 |
my $item_map = MapItemsToHoldRequests( $hold_requests, $available_items, $branches_to_use, $transport_cost_matrix ); |
964 |
my $item_map = MapItemsToHoldRequests( $hold_requests, $available_items, $branches_to_use, $transport_cost_matrix ); |
963 |
$result->{mapped_items} = scalar( keys %{$item_map} ); |
965 |
$result->{mapped_items} = scalar( keys %{$item_map} ); |
964 |
- |
|
|