From dabffa9bcb4fdb1534e4101ea112da352f857b32 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Wed, 3 Jun 2015 09:51:49 -0400 Subject: [PATCH] Bug 14320 - WIP --- C4/Circulation.pm | 30 +++++++++++++++++++++++------- 1 files changed, 23 insertions(+), 7 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index f991680..3ba2793 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -2700,18 +2700,34 @@ sub CanBookBeRenewed { } } + # Avoid the overhead of GetMemberDetails, we don't need all that data + my @borrowers = $schema->resultset('Borrower')->search( + { -in => \@borrowernumbers }, + { + result_class => 'DBIx::Class::ResultClass::HashRefInflator', + } + ); + + # Avoid the overhead of GetMemberDetails, we don't need all that data + my @items = $schema->resultset('Item')->search( + { -in => \@itemnumbers }, + { + result_class => 'DBIx::Class::ResultClass::HashRefInflator', + } + ); + # If the count of the union of the lists of reservable items for each borrower # is equal or greater than the number of borrowers, we know that all reserves # can be filled with available items. We can get the union of the sets simply # by pushing all the elements onto an array and removing the duplicates. my @reservable; - foreach my $b (@borrowernumbers) { - my ($borr) = C4::Members::GetMemberDetails($b); - foreach my $i (@itemnumbers) { - my $item = GetItem($i); - if ( IsAvailableForItemLevelRequest( $item, $borr ) - && CanItemBeReserved( $b, $i ) - && !IsItemOnHoldAndFound($i) ) + foreach my $b (@borrowers) { + warn "B: $b"; + foreach my $i (@items) { + warn "I: $i"; + if ( IsAvailableForItemLevelRequest( $i, $b ) + && CanItemBeReserved( $b->{borrowernumber}, $i->{itemnumber} ) + && !IsItemOnHoldAndFound( $i->{itemnumber} ) ) { push( @reservable, $i ); } -- 1.7.2.5