Bugzilla – Attachment 144442 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.27 KB, created by
Matt Blenkinsop
on 2022-12-06 10:58:02 UTC
(
hide
)
Description:
Bug 32013: Autorenewal batch indexing
Filename:
MIME Type:
Creator:
Matt Blenkinsop
Created:
2022-12-06 10:58:02 UTC
Size:
4.27 KB
patch
obsolete
>From ceef50cdd1a925abeeef072700d700440563a8bb 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 >--- > C4/Circulation.pm | 6 +++++- > misc/cronjobs/automatic_renewals.pl | 9 ++++++++- > 2 files changed, 13 insertions(+), 2 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 336ce9490a..76fae007cc 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -3029,6 +3029,9 @@ C<$seen> is a boolean flag indicating if the item was seen or not during the ren > informs the incrementing of the unseen_renewals column. If this flag is not supplied, we > fallback to a true value > >+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 { >@@ -3039,6 +3042,7 @@ sub AddRenewal { > my $lastreneweddate = shift || dt_from_string(); > my $skipfinecalc = shift; > my $seen = shift; >+ my $skip_record_index = shift; > > # Fallback on a 'seen' renewal > $seen = defined $seen && $seen == 0 ? 0 : 1; >@@ -3131,7 +3135,7 @@ sub AddRenewal { > $renews = ( $item_object->renewals || 0 ) + 1; > $item_object->renewals($renews); > $item_object->onloan($datedue); >- $item_object->store({ log_action => 0 }); >+ $item_object->store({ log_action => 0, skip_record_index => $skip_record_index }); > > # Charge a new rental fee, if applicable > my ( $charge, $type ) = GetIssuingCharges( $itemnumber, $borrowernumber ); >diff --git a/misc/cronjobs/automatic_renewals.pl b/misc/cronjobs/automatic_renewals.pl >index 4884eee2f3..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; > >@@ -180,7 +181,8 @@ while ( my $auto_renew = $auto_renews->next ) { > $auto_renew->issue_id, $auto_renew->borrowernumber, $auto_renew->itemnumber, $confirm ? 'will' : 'would'; > } > if ($confirm){ >- my $date_due = AddRenewal( $auto_renew->borrowernumber, $auto_renew->itemnumber, $auto_renew->branchcode, undef, undef, undef, 0 ); >+ 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.37.1 (Apple Git-137.1)
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