Bugzilla – Attachment 149276 Details for
Bug 32013
Autorenewals is effectively a bulk action and should be treated as such
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32013: Autorenewal batch indexing
Bug-32013-Autorenewal-batch-indexing.patch (text/plain), 4.67 KB, created by
Nick Clemens (kidclamp)
on 2023-04-07 13:41:01 UTC
(
hide
)
Description:
Bug 32013: Autorenewal batch indexing
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2023-04-07 13:41:01 UTC
Size:
4.67 KB
patch
obsolete
>From 4bba81b46618e07097e22b5e637b60d71763318e Mon Sep 17 00:00:00 2001 >From: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> >Date: Tue, 6 Dec 2022 10:39:14 +0000 >Subject: [PATCH] Bug 32013: Autorenewal batch indexing > >The automatic_renewals.pl cron script currently loops through items for automatic renewal and calls the indexer for each one individually. skip_record_index has now been added as a parameter to the AddRenewal function to skip the indexing process. The item numbers are now added to an array and then the indexer is called once from within automatic_renewals.pl and passed the array to queue one indexing job instead of multiple jobs. > >Test plan: >1) AddRenewal uses Koha::Items->store() to trigger the indexing process. Run prove -vv t/db_dependent/Koha/SearchEngine/Indexer.t and check tests 5,6,29,30. These tests prove whether passing skip_record_index to store() triggers or skips the indexing process. All four tests should pass to show that skip_index_records can prevent the indexing being triggered. >2) Add multiple renewals that are able to be autorenewed and run the automatic_renewals.pl script. There should be multiple items queued in zebraqueue. >3) Apply patch and try again >4) There should now only be one job queued in zebraqueue > >Mentored-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > C4/Circulation.pm | 15 +++++++++++---- > misc/cronjobs/automatic_renewals.pl | 7 +++++++ > 2 files changed, 18 insertions(+), 4 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index f1851ed283..6bba369114 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -3083,6 +3083,9 @@ fallback to a true value > > C<$automatic> is a boolean flag indicating the renewal was triggered automatically and not by a person ( librarian or patron ) > >+C<$skip_record_index> is an optional boolean flag to indicate whether queuing the search indexing >+should be skipped for this renewal. >+ > =cut > > sub AddRenewal { >@@ -3094,6 +3097,7 @@ sub AddRenewal { > my $skipfinecalc = shift; > my $seen = shift; > my $automatic = shift; >+ my $skip_record_index = shift; > > # Fallback on a 'seen' renewal > $seen = defined $seen && $seen == 0 ? 0 : 1; >@@ -3188,7 +3192,7 @@ sub AddRenewal { > $renews = ( $item_object->renewals || 0 ) + 1; > $item_object->renewals($renews); > $item_object->onloan($datedue); >- # Don't index as we are in a transaction >+ # Don't index as we are in a transaction, skip hardcoded here > $item_object->store({ log_action => 0, skip_record_index => 1 }); > > # Charge a new rental fee, if applicable >@@ -3274,9 +3278,12 @@ sub AddRenewal { > } > }); > }); >- # We index now, after the transaction is committed >- my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX }); >- $indexer->index_records( $item_object->biblionumber, "specialUpdate", "biblioserver" ); >+ >+ unless( $skip_record_index ){ >+ # We index now, after the transaction is committed >+ my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX }); >+ $indexer->index_records( $item_object->biblionumber, "specialUpdate", "biblioserver" ); >+ } > > return $datedue; > } >diff --git a/misc/cronjobs/automatic_renewals.pl b/misc/cronjobs/automatic_renewals.pl >index 0a843843ab..bf048c09d0 100755 >--- a/misc/cronjobs/automatic_renewals.pl >+++ b/misc/cronjobs/automatic_renewals.pl >@@ -148,6 +148,7 @@ print "found " . $auto_renews->count . " auto renewals\n" if $verbose; > > my $renew_digest = {}; > my %report; >+my @item_renewal_ids; > while ( my $auto_renew = $auto_renews->next ) { > print "examining item '" . $auto_renew->itemnumber . "' to auto renew\n" if $verbose; > >@@ -181,6 +182,7 @@ while ( my $auto_renew = $auto_renews->next ) { > } > if ($confirm){ > my $date_due = AddRenewal( $auto_renew->borrowernumber, $auto_renew->itemnumber, $auto_renew->branchcode, undef, undef, undef, 0, 1 ); >+ push @item_renewal_ids, $auto_renew->itemnumber; > $auto_renew->auto_renew_error(undef)->store; > } > push @{ $report{ $auto_renew->borrowernumber } }, $auto_renew >@@ -226,6 +228,11 @@ while ( my $auto_renew = $auto_renews->next ) { > > } > >+if( @item_renewal_ids ){ >+ my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX }); >+ $indexer->index_records( \@item_renewal_ids, "specialUpdate", "biblioserver" ); >+} >+ > if ( $send_notices && $confirm ) { > for my $borrowernumber ( keys %report ) { > my $patron = Koha::Patrons->find($borrowernumber); >-- >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 32013
:
144442
|
144464
|
145150
|
145151
|
145152
|
145186
|
145187
|
145188
| 149276 |
149277
|
149278
|
149279