Bug 32565: (follow-up) Tidy

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit 4da2e1444b)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
Nick Clemens 2024-04-19 11:25:58 +00:00 committed by Fridolin Somers
parent c23b90e11b
commit fcc65787aa
3 changed files with 25 additions and 24 deletions

View file

@ -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";

View file

@ -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" } );

View file

@ -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;