From 6b120d34a45c2f14081546c059c97e78647cbbab Mon Sep 17 00:00:00 2001 From: Joe Atzberger Date: Fri, 23 Jan 2009 11:57:58 -0600 Subject: [PATCH] Cleanup, pod fix and FIXME's added. Signed-off-by: Galen Charlton --- misc/cronjobs/holds/build_holds_queue.pl | 67 +++++++++++++----------- 1 file changed, 35 insertions(+), 32 deletions(-) diff --git a/misc/cronjobs/holds/build_holds_queue.pl b/misc/cronjobs/holds/build_holds_queue.pl index 8b48a8fa79..4aca28db64 100755 --- a/misc/cronjobs/holds/build_holds_queue.pl +++ b/misc/cronjobs/holds/build_holds_queue.pl @@ -3,6 +3,9 @@ # Script Name: build_holds_queue.pl # Description: builds a holds queue in the tmp_holdsqueue table #----------------------------------- +# FIXME: add command-line options for verbosity and summary +# FIXME: expand perldoc, explain intended logic +# FIXME: refactor all subroutines into C4 for testability use strict; use warnings; @@ -29,33 +32,33 @@ my $dbh = C4::Context->dbh; $dbh->do("DELETE FROM tmp_holdsqueue"); # clear the old table for new info $dbh->do("DELETE FROM hold_fill_targets"); -my $total_bibs = 0; -my $total_requests = 0; +my $total_bibs = 0; +my $total_requests = 0; my $total_available_items = 0; -my $num_items_mapped = 0; +my $num_items_mapped = 0; my @branches_to_use = _get_branches_to_pull_from(); foreach my $biblionumber (@$bibs_with_pending_requests) { $total_bibs++; - my $hold_requests = GetPendingHoldRequestsForBib($biblionumber); - $total_requests += scalar(@$hold_requests); + my $hold_requests = GetPendingHoldRequestsForBib($biblionumber); my $available_items = GetItemsAvailableToFillHoldRequestsForBib($biblionumber, @branches_to_use); + $total_requests += scalar(@$hold_requests); $total_available_items += scalar(@$available_items); my $item_map = MapItemsToHoldRequests($hold_requests, $available_items, @branches_to_use); - if (defined($item_map)) { - $num_items_mapped += scalar(keys %$item_map); - CreatePicklistFromItemMap($item_map); - AddToHoldTargetMap($item_map); - if ((scalar(keys %$item_map) < scalar(@$hold_requests)) and - (scalar(keys %$item_map) < scalar(@$available_items))) { - # DOUBLE CHECK, but this is probably OK - unfilled item-level requests - # FIXME - #warn "unfilled requests for $biblionumber"; - #warn Dumper($hold_requests); - #warn Dumper($available_items); - #warn Dumper($item_map); - } + + (defined($item_map)) or next; + + my $item_map_size = scalar(keys %$item_map); + $num_items_mapped += $item_map_size; + CreatePicklistFromItemMap($item_map); + AddToHoldTargetMap($item_map); + if (($item_map_size < scalar(@$hold_requests )) and + ($item_map_size < scalar(@$available_items))) { + # DOUBLE CHECK, but this is probably OK - unfilled item-level requests + # FIXME + #warn "unfilled requests for $biblionumber"; + #warn Dumper($hold_requests), Dumper($available_items), Dumper($item_map); } } @@ -101,14 +104,14 @@ Returns an arrayref of hashrefs to pending, unfilled hold requests on the bib identified by $biblionumber. The following keys are present in each hashref: -biblionumber -borrowernumber -itemnumber -priority -branchcode -reservedate -reservenotes -borrowerbranch + biblionumber + borrowernumber + itemnumber + priority + branchcode + reservedate + reservenotes + borrowerbranch The arrayref is sorted in order of increasing priority. @@ -147,12 +150,12 @@ Returns an arrayref of items available to fill hold requests for the bib identified by C<$biblionumber>. An item is available to fill a hold request if and only if: -* it is not on loan -* it is not withdrawn -* it is not marked notforloan -* it is not currently in transit -* it is not lost -* it is not sitting on the hold shelf + * it is not on loan + * it is not withdrawn + * it is not marked notforloan + * it is not currently in transit + * it is not lost + * it is not sitting on the hold shelf =cut -- 2.39.2