2 #-----------------------------------
3 # Script Name: build_holds_queue.pl
4 # Description: builds a holds queue in the tmp_holdsqueue table
5 #-----------------------------------
6 # FIXME: add command-line options for verbosity and summary
7 # FIXME: expand perldoc, explain intended logic
11 use Getopt::Long qw( GetOptions );
12 use Pod::Usage qw( pod2usage );
15 use C4::HoldsQueue qw(CreateQueue);
16 use C4::Log qw( cronlogaction );
17 use Koha::Script -cron;
21 build_holds_queue.pl - Rebuild the holds queue
25 build_holds_queue.pl [-f]
28 -h --help Brief help message
29 -m --man Full documentation
30 -f --force Run holds queue builder even if RealTimeHoldsQueue is enabled
38 Print a brief help message and exits.
42 Prints the manual page and exits.
46 allows this script to rebuild the entire holds queue even if the realtimeholdsqueue system preference is enabled.
48 =item b<--unallocated>
50 prevents deletion of current queue and allows the script to only deal with holds not currently in the queue.
51 This is useful when using the realtimeholdsqueue and skipping closed libraries, or allowing holds in the future
52 This allows the script to catch holds that may have become active without triggering a real time update.
58 This script builds or rebuilds the entire holds queue.
67 my $command_line_options = join( " ", @ARGV );
73 'u|unallocated' => \$unallocated
75 pod2usage(1) if $help;
76 pod2usage( -exitval => 0, -verbose => 2 ) if $man;
78 my $rthq = C4::Context->preference('RealTimeHoldsQueue');
80 if ( $rthq && !$force ) {
81 say "RealTimeHoldsQueue system preference is enabled, holds queue not built.";
82 say "Use --force to force building the holds queue.";
86 cronlogaction( { info => $command_line_options } );
88 CreateQueue( { unallocated => $unallocated } );
90 cronlogaction( { action => 'End', info => "COMPLETED" } );