@@ -, +, @@ --- circ/pendingreserves.pl | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) --- a/circ/pendingreserves.pl +++ a/circ/pendingreserves.pl @@ -222,6 +222,20 @@ my $patrons_count = { } }; +my $all_holds = { + map { $_->biblionumber => $_ } @{ Koha::Holds->search( + {%where}, + { + prefetch => [ 'borrowernumber', 'itembib', 'biblio' ], + order_by => 'priority', + alias => 'reserve', + group_by => 'reserve.biblionumber', + } + )->as_list + } +}; + + # make final holds_info array and fill with info my @holds_info; foreach my $bibnum ( @biblionumbers ){ @@ -275,13 +289,7 @@ foreach my $bibnum ( @biblionumbers ){ $hold_info->{pull_count} = $pull_count; # get other relevant information - my $res_info = Koha::Holds->search( - { 'reserve.biblionumber' => $bibnum, %where }, - { prefetch => [ 'borrowernumber', 'itembib', 'biblio' ], - order_by => 'priority', - alias => 'reserve' - } - )->next; # get first item in results + my $res_info = $all_holds->{$bibnum}; $hold_info->{patron} = $res_info->patron; $hold_info->{item} = $res_info->item; $hold_info->{biblio} = $res_info->biblio; --