From 3df8ed47b447c662422153acb3304cfeb1440c18 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 Content-Type: text/plain; charset=utf-8 Removes the loop by moving the onloan test to the query. Test plan: Run the test again. Signed-off-by: Marcel de Rooy --- 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 db8b04a..2f23036 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.1.4