Bugzilla – Attachment 150784 Details for
Bug 33691
Improve query for do_check_for_previous_checkout
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33691: Improve query for do_check_for_previous_checkout
Bug-33691-Improve-query-for-docheckforpreviouschec.patch (text/plain), 2.33 KB, created by
Kyle M Hall (khall)
on 2023-05-05 17:58:20 UTC
(
hide
)
Description:
Bug 33691: Improve query for do_check_for_previous_checkout
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2023-05-05 17:58:20 UTC
Size:
2.33 KB
patch
obsolete
>From 12e2524cd3e0c8eebe422865f52be64fbd27959c Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Fri, 5 May 2023 13:45:59 -0400 >Subject: [PATCH] Bug 33691: Improve query for do_check_for_previous_checkout > >do_check_for_previous_checkout will pass a list of itemnumbers as part of the query. This could be hundreds of items or more. It makes sense to check by biblionumber instead when possible. > >Test Plan: >1) prove t/db_dependent/Patron/Borrower_PrevCheckout.t >2) Apply this patch >3) prove t/db_dependent/Patron/Borrower_PrevCheckout.t >4) Test still pass! >--- > Koha/Patron.pm | 23 ++++++++++++----------- > 1 file changed, 12 insertions(+), 11 deletions(-) > >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index f0e1734217..2e8a3dfe74 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -726,21 +726,23 @@ $PATRON, 0 otherwise. > sub do_check_for_previous_checkout { > my ( $self, $item ) = @_; > >+ my $criteria = { borrowernumber => $self->borrowernumber }; >+ >+ my $attrs = {}; >+ > my @item_nos; > my $biblio = Koha::Biblios->find( $item->{biblionumber} ); >+ # >+ # Create (old)issues search criteria > if ( $biblio->is_serial ) { >- push @item_nos, $item->{itemnumber}; >+ $criteria->{itemnumber} = $item->{itemnumber}; > } else { > # Get all itemnumbers for given bibliographic record. > @item_nos = $biblio->items->get_column( 'itemnumber' ); >+ $criteria->{'biblio.biblionumber'} = $item->{biblionumber}; >+ $attrs->{join} = { 'item' => 'biblio' }; > } > >- # Create (old)issues search criteria >- my $criteria = { >- borrowernumber => $self->borrowernumber, >- itemnumber => \@item_nos, >- }; >- > my $delay = C4::Context->preference('CheckPrevCheckoutDelay') || 0; > if ($delay) { > my $dtf = Koha::Database->new->schema->storage->datetime_parser; >@@ -749,12 +751,11 @@ sub do_check_for_previous_checkout { > } > > # Check current issues table >- my $issues = Koha::Checkouts->search($criteria); >- return 1 if $issues->count; # 0 || N >+ return 1 >+ if Koha::Checkouts->search( $criteria, $attrs )->count; > > # Check old issues table >- my $old_issues = Koha::Old::Checkouts->search($criteria); >- return $old_issues->count; # 0 || N >+ return Koha::Old::Checkouts->search( $criteria, $attrs )->count; > } > > =head3 is_debarred >-- >2.30.2
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 33691
:
150782
|
150783
|
150784
|
150785
|
150818