View | Details | Raw Unified | Return to bug 28833
Collapse All | Expand All

(-)a/C4/HoldsQueue.pm (-13 / +16 lines)
Lines 258-271 sub CreateQueue { Link Here
258
258
259
    my $bibs_with_pending_requests = GetBibsWithPendingHoldRequests();
259
    my $bibs_with_pending_requests = GetBibsWithPendingHoldRequests();
260
260
261
    # Split the list of bibs into groups to run in parallel
261
    # Split the list of bibs into chunks to run in parallel
262
    if ( $loops > 1 ) {
262
    if ( $loops > 1 ) {
263
        my $bibs_per_chunk = ceil( scalar @$bibs_with_pending_requests / $loops );
263
        my $i = 0;
264
        $bibs_per_chunk = @$bibs_with_pending_requests if @$bibs_with_pending_requests <= $bibs_per_chunk;
264
        while (@$bibs_with_pending_requests) {
265
        my @chunks;
265
            push( @{ $chunks[$i] }, pop(@$bibs_with_pending_requests) );
266
266
267
        push( @chunks, [ splice @$bibs_with_pending_requests, 0, $bibs_per_chunk ] ) while @$bibs_with_pending_requests;
267
            $i++;
268
        push( @{$chunks[0]}, @$bibs_with_pending_requests ); # Add any remainders to the first parallel process
268
            $i = 0 if $i >= $loops;
269
        }
269
270
270
        my $pm = Parallel::ForkManager->new($loops);
271
        my $pm = Parallel::ForkManager->new($loops);
271
272
Lines 335-346 that have one or more unfilled hold requests. Link Here
335
sub GetBibsWithPendingHoldRequests {
336
sub GetBibsWithPendingHoldRequests {
336
    my $dbh = C4::Context->dbh;
337
    my $dbh = C4::Context->dbh;
337
338
338
    my $bib_query = "SELECT DISTINCT biblionumber
339
    my $bib_query = "SELECT biblionumber,
339
                     FROM reserves
340
                            COUNT(biblionumber) AS holds_count
340
                     WHERE found IS NULL
341
                     FROM   reserves
341
                     AND priority > 0
342
                     WHERE  found IS NULL
342
                     AND reservedate <= CURRENT_DATE()
343
                        AND priority > 0
343
                     AND suspend = 0
344
                        AND reservedate <= CURRENT_DATE()
345
                        AND suspend = 0
346
                     GROUP BY biblionumber
347
                     ORDER BY biblionumber DESC
344
                     ";
348
                     ";
345
    my $sth = $dbh->prepare($bib_query);
349
    my $sth = $dbh->prepare($bib_query);
346
350
347
- 

Return to bug 28833