From fcc65787aaf100c0684a53226b30b1c70fda4a52 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 19 Apr 2024 11:25:58 +0000 Subject: [PATCH] Bug 32565: (follow-up) Tidy Signed-off-by: Katrin Fischer (cherry picked from commit 4da2e1444be2f80f9a9a87a73af55bec1fe52f98) Signed-off-by: Fridolin Somers --- C4/HoldsQueue.pm | 31 ++++++++++++------------ misc/cronjobs/holds/build_holds_queue.pl | 14 +++++------ t/db_dependent/HoldsQueue.t | 4 +-- 3 files changed, 25 insertions(+), 24 deletions(-) diff --git a/C4/HoldsQueue.pm b/C4/HoldsQueue.pm index 8fee4ca452..8562ac2706 100644 --- a/C4/HoldsQueue.pm +++ b/C4/HoldsQueue.pm @@ -166,12 +166,12 @@ Top level function that turns reserves into tmp_holdsqueue and hold_fill_targets =cut sub CreateQueue { - my $params = shift; + my $params = shift; my $unallocated = $params->{unallocated}; - my $dbh = C4::Context->dbh; + my $dbh = C4::Context->dbh; - unless( $unallocated ){ - $dbh->do("DELETE FROM tmp_holdsqueue"); # clear the old table for new info + unless ($unallocated) { + $dbh->do("DELETE FROM tmp_holdsqueue"); # clear the old table for new info $dbh->do("DELETE FROM hold_fill_targets"); } @@ -200,7 +200,8 @@ sub CreateQueue { $total_bibs++; my $result = update_queue_for_biblio( - { biblio_id => $biblionumber, + { + biblio_id => $biblionumber, branches_to_use => $branches_to_use, transport_cost_matrix => $transport_cost_matrix, unallocated => $unallocated @@ -243,7 +244,7 @@ sub GetBibsWithPendingHoldRequests { =head2 GetPendingHoldRequestsForBib - my $requests = GetPendingHoldRequestsForBib({ biblionumber => $biblionumber, unallocated => $unallocated }); + my $requests = GetPendingHoldRequestsForBib( { biblionumber => $biblionumber, unallocated => $unallocated } ); Returns an arrayref of hashrefs to pending, unfilled hold requests on the bib identified by $biblionumber. Optionally returns only unallocated holds. The following keys @@ -263,9 +264,9 @@ The arrayref is sorted in order of increasing priority. =cut sub GetPendingHoldRequestsForBib { - my $params = shift; + my $params = shift; my $biblionumber = $params->{biblionumber}; - my $unallocated = $params->{unallocated}; + my $unallocated = $params->{unallocated}; my $dbh = C4::Context->dbh; @@ -278,8 +279,8 @@ sub GetPendingHoldRequestsForBib { AND priority > 0 AND reservedate <= CURRENT_DATE() AND suspend = 0 "; - $request_query .= "AND reserve_id NOT IN (SELECT reserve_id FROM hold_fill_targets) " if $unallocated; - $request_query .= "ORDER BY priority"; + $request_query .= "AND reserve_id NOT IN (SELECT reserve_id FROM hold_fill_targets) " if $unallocated; + $request_query .= "ORDER BY priority"; my $sth = $dbh->prepare($request_query); $sth->execute($biblionumber); @@ -313,17 +314,17 @@ sub GetItemsAvailableToFillHoldRequestsForBib { my $items_query = "SELECT items.itemnumber, homebranch, holdingbranch, itemtypes.itemtype AS itype FROM items "; - if (C4::Context->preference('item-level_itypes')) { - $items_query .= "LEFT JOIN itemtypes ON (itemtypes.itemtype = items.itype) "; + if ( C4::Context->preference('item-level_itypes') ) { + $items_query .= "LEFT JOIN itemtypes ON (itemtypes.itemtype = items.itype) "; } else { - $items_query .= "JOIN biblioitems USING (biblioitemnumber) + $items_query .= "JOIN biblioitems USING (biblioitemnumber) LEFT JOIN itemtypes USING (itemtype) "; } - $items_query .= " LEFT JOIN branchtransfers ON ( + $items_query .= " LEFT JOIN branchtransfers ON ( items.itemnumber = branchtransfers.itemnumber AND branchtransfers.datearrived IS NULL AND branchtransfers.datecancelled IS NULL )"; - $items_query .= " WHERE items.notforloan = 0 + $items_query .= " WHERE items.notforloan = 0 AND holdingbranch IS NOT NULL AND itemlost = 0 AND withdrawn = 0"; diff --git a/misc/cronjobs/holds/build_holds_queue.pl b/misc/cronjobs/holds/build_holds_queue.pl index 06b02041e5..600d0091bd 100755 --- a/misc/cronjobs/holds/build_holds_queue.pl +++ b/misc/cronjobs/holds/build_holds_queue.pl @@ -59,17 +59,17 @@ This script builds or rebuilds the entire holds queue. =cut -my $help = 0; -my $man = 0; -my $force = 0; +my $help = 0; +my $man = 0; +my $force = 0; my $unallocated = 0; my $command_line_options = join( " ", @ARGV ); GetOptions( - 'h|help' => \$help, - 'm|man' => \$man, - 'f|force' => \$force, + 'h|help' => \$help, + 'm|man' => \$man, + 'f|force' => \$force, 'u|unallocated' => \$unallocated ); pod2usage(1) if $help; @@ -85,6 +85,6 @@ if ( $rthq && !$force ) { cronlogaction( { info => $command_line_options } ); -CreateQueue({ unallocated => $unallocated }); +CreateQueue( { unallocated => $unallocated } ); cronlogaction( { action => 'End', info => "COMPLETED" } ); diff --git a/t/db_dependent/HoldsQueue.t b/t/db_dependent/HoldsQueue.t index 987aba21ee..11bcad4156 100755 --- a/t/db_dependent/HoldsQueue.t +++ b/t/db_dependent/HoldsQueue.t @@ -2254,14 +2254,14 @@ subtest "Test unallocated option" => sub { my $original_timestamp = $hold->timestamp; - sleep 2; # Allow time to pass after first hold was placed + sleep 2; # Allow time to pass after first hold was placed C4::HoldsQueue::CreateQueue(); $queue_rs = $schema->resultset('TmpHoldsqueue')->search( { biblionumber => $item1->biblionumber } ); $hold = $queue_rs->next; isnt( $hold->timestamp, $original_timestamp, "Hold was reallocated when queue fully rebuilt" ); my $after_rebuild_timestamp = $hold->timestamp; - sleep 2; # Allow time to pass after first full rebuild + sleep 2; # Allow time to pass after first full rebuild C4::HoldsQueue::CreateQueue( { unallocated => 1 } ); $queue_rs = $schema->resultset('TmpHoldsqueue')->search( { biblionumber => $item1->biblionumber } ); $hold = $queue_rs->next; -- 2.39.5