From b038bb131082c7c165bc2a71a44e974e15ebd839 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Fri, 7 Apr 2017 11:56:52 +0200 Subject: [PATCH] Bug 18208: [QA Follow-up] Get count from Koha::Items Removes the loop by moving the onloan test to the query. Test plan: Run the test again. Signed-off-by: Marcel de Rooy Signed-off-by: Kyle M Hall --- Koha/Filter/MARC/EmbedItemsAvailability.pm | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/Koha/Filter/MARC/EmbedItemsAvailability.pm b/Koha/Filter/MARC/EmbedItemsAvailability.pm index db8b04a799..2f23036212 100644 --- a/Koha/Filter/MARC/EmbedItemsAvailability.pm +++ b/Koha/Filter/MARC/EmbedItemsAvailability.pm @@ -74,13 +74,10 @@ sub _processrecord { my ($biblionumber_field, $biblionumber_subfield) = GetMarcFromKohaField("biblio.biblionumber", ''); my $biblionumber = $record->field($biblionumber_field)->subfield($biblionumber_subfield); - my $not_onloan_items = 0; - my $items = Koha::Items->search({ biblionumber => $biblionumber }); - - while ( my $item = $items->next ) { - $not_onloan_items++ - if not $item->onloan; - } + my $not_onloan_items = Koha::Items->search({ + biblionumber => $biblionumber, + onloan => undef, + })->count; # check for field 999 my $destination_field = $record->field('999'); -- 2.39.5