Bugzilla – Attachment 86481 Details for
Bug 22330
Transfer limits should be respected for placing holds in staff interface and APIs
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22330: Cache item and library objects when building the holds queue
Bug-22330-Cache-item-and-library-objects-when-buil.patch (text/plain), 5.87 KB, created by
Kyle M Hall (khall)
on 2019-03-11 18:37:21 UTC
(
hide
)
Description:
Bug 22330: Cache item and library objects when building the holds queue
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2019-03-11 18:37:21 UTC
Size:
5.87 KB
patch
obsolete
>From 293534c9c2476e80e16a8ac6af6fcdbc0da51543 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Wed, 13 Feb 2019 15:45:28 -0500 >Subject: [PATCH] Bug 22330: Cache item and library objects when building the > holds queue > >--- > C4/HoldsQueue.pm | 19 +++++++++++-------- > 1 file changed, 11 insertions(+), 8 deletions(-) > >diff --git a/C4/HoldsQueue.pm b/C4/HoldsQueue.pm >index 0028d798dc..d55e7e3161 100755 >--- a/C4/HoldsQueue.pm >+++ b/C4/HoldsQueue.pm >@@ -369,7 +369,6 @@ sub GetItemsAvailableToFillHoldRequestsForBib { > sub MapItemsToHoldRequests { > my ($hold_requests, $available_items, $branches_to_use, $transport_cost_matrix) = @_; > >- > # handle trival cases > return unless scalar(@$hold_requests) > 0; > return unless scalar(@$available_items) > 0; >@@ -379,6 +378,10 @@ sub MapItemsToHoldRequests { > grep { defined($_->{itemnumber}) } > @$hold_requests; > >+ map { $_->{_object} = Koha::Items->find( $_->{itemnumber} ) } @$available_items; >+ my $libraries = {}; >+ map { $libraries->{$_->id} = $_ } Koha::Libraries->search(); >+ > # group available items by itemnumber > my %items_by_itemnumber = map { $_->{itemnumber} => $_ } @$available_items; > >@@ -409,7 +412,7 @@ sub MapItemsToHoldRequests { > || ( $item->{holdallowed} == 1 > && $item->{homebranch} ne $request->{borrowerbranch} ); > >- next unless Koha::Items->find( $item->{itemnumber} )->can_be_transferred( { to => scalar Koha::Libraries->find( $request->{branchcode} ) } ); >+ next unless $item->{_object}->can_be_transferred( { to => $libraries->{ $request->{branchcode} } } ); > > my $local_holds_priority_item_branchcode = > $item->{$LocalHoldsPriorityItemControl}; >@@ -465,7 +468,7 @@ sub MapItemsToHoldRequests { > and ( !$request->{itemtype} # If hold itemtype is set, item's itemtype must match > || $items_by_itemnumber{ $request->{itemnumber} }->{itype} eq $request->{itemtype} ) > ) >- and Koha::Items->find( $request->{itemnumber} )->can_be_transferred( { to => scalar Koha::Libraries->find( $request->{branchcode} ) } ) >+ and $items_by_itemnumber{ $request->{itemnumber} }->{_object}->can_be_transferred( { to => $libraries->{ $request->{branchcode} } } ) > > ) > { >@@ -513,7 +516,7 @@ sub MapItemsToHoldRequests { > my $holding_branch_items = $items_by_branch{$pickup_branch}; > if ( $holding_branch_items ) { > foreach my $item (@$holding_branch_items) { >- next unless Koha::Items->find( $item->{itemnumber} )->can_be_transferred( { to => scalar Koha::Libraries->find( $request->{branchcode} ) } ); >+ next unless $items_by_itemnumber{ $item->{itemnumber} }->{_object}->can_be_transferred( { to => $libraries->{ $request->{branchcode} } } ); > > if ( > $request->{borrowerbranch} eq $item->{homebranch} >@@ -537,7 +540,7 @@ sub MapItemsToHoldRequests { > my $holding_branch_items = $items_by_branch{$holdingbranch}; > foreach my $item (@$holding_branch_items) { > next if $request->{borrowerbranch} ne $item->{homebranch}; >- next unless Koha::Items->find( $item->{itemnumber} )->can_be_transferred( { to => scalar Koha::Libraris->find( $request->{branchcode} ) } ); >+ next unless $items_by_itemnumber{ $item->{itemnumber} }->{_object}->can_be_transferred( { to => $libraries->{ $request->{branchcode} } } ); > > # Don't fill item level holds that contravene the hold pickup policy at this time > next unless $item->{hold_fulfillment_policy} eq 'any' >@@ -574,7 +577,7 @@ sub MapItemsToHoldRequests { > foreach my $item (@$holding_branch_items) { > next if $pickup_branch ne $item->{homebranch}; > next if ( $item->{holdallowed} == 1 && $item->{homebranch} ne $request->{borrowerbranch} ); >- next unless Koha::Items->find( $item->{itemnumber} )->can_be_transferred( { to => scalar Koha::Libraries->find( $request->{branchcode} ) } ); >+ next unless $items_by_itemnumber{ $item->{itemnumber} }->{_object}->can_be_transferred( { to => $libraries->{ $request->{branchcode} } } ); > > # Don't fill item level holds that contravene the hold pickup policy at this time > next unless $item->{hold_fulfillment_policy} eq 'any' >@@ -603,7 +606,7 @@ sub MapItemsToHoldRequests { > next unless ( !$request->{itemtype} > || $current_item->{itype} eq $request->{itemtype} ); > >- next unless Koha::Items->find( $current_item->{itemnumber} )->can_be_transferred( { to => scalar Koha::Libraries->find( $request->{branchcode} ) } ); >+ next unless $items_by_itemnumber{ $current_item->{itemnumber} }->{_object}->can_be_transferred( { to => $libraries->{ $request->{branchcode} } } ); > > $itemnumber = $current_item->{itemnumber}; > last; # quit this loop as soon as we have a suitable item >@@ -629,7 +632,7 @@ sub MapItemsToHoldRequests { > next unless ( !$request->{itemtype} > || $item->{itype} eq $request->{itemtype} ); > >- next unless Koha::Items->find( $item->{itemnumber} )->can_be_transferred( { to => scalar Koha::Libraries->find( $request->{branchcode} ) } ); >+ next unless $items_by_itemnumber{ $item->{itemnumber} }->{_object}->can_be_transferred( { to => $libraries->{ $request->{branchcode} } } ); > > $itemnumber = $item->{itemnumber}; > $holdingbranch = $branch; >-- >2.17.2 (Apple Git-113)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 22330
:
85067
|
85068
|
86479
|
86480
|
86481
|
86482
|
86758
|
86759
|
86760
|
86779
|
86802
|
86803
|
86804
|
86805
|
86806
|
86807