Bugzilla – Attachment 170902 Details for
Bug 37790
Prevent indexing and holds queue updates when running update_localuse_from_statistics.pl
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 37790: Add skip indexing and holds queue options and verbosity to update localuse script
Bug-37790-Add-skip-indexing-and-holds-queue-option.patch (text/plain), 4.35 KB, created by
Nick Clemens (kidclamp)
on 2024-08-30 11:13:55 UTC
(
hide
)
Description:
Bug 37790: Add skip indexing and holds queue options and verbosity to update localuse script
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2024-08-30 11:13:55 UTC
Size:
4.35 KB
patch
obsolete
>From 23682c043487568b471c604f722100d47e229bf7 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Fri, 30 Aug 2024 11:05:59 +0000 >Subject: [PATCH] Bug 37790: Add skip indexing and holds queue options and > verbosity to update localuse script > >This patch skips record indexing and real time holds queue updates when updating the localuse field >from statistics. A note is added to the script that the user should reindex if the localuse field is mapped. > >Additionally a verbose option is added to the script, and doubled use of GetOptions is removed. > >Lastly, a check is added to confirm the items value is being changed before the value is stored. > >To test: > 1 - Enable the real time holds queue > 2 - Enable Elasticsearch > 3 - perl misc/maintenance/update_localuse_from_statistics.pl --confirm > 4 - Note all items are touched and reported > 5 - Check the background jobs table - there are many jobs generated > 6 - Apply patch > 7 - perl misc/maintenance/update_localuse_from_statistics.pl --confirm > 8 - Note 0 items are reported updated, no new background jobs > 9 - perl misc/maintenance/update_localuse_from_statistics.pl --confirm --verbose >10 - No items reported >11 - Update some items in the DB > UPDATE items SET localuse = 99 WHERE itemnumber LIKE '%9'; >12 - perl misc/maintenance/update_localuse_from_statistics.pl --confirm >13 - Only the number of items changed above reported >14 - UPDATE items SET localuse = 99 WHERE itemnumber LIKE '%9'; >15 - perl misc/maintenance/update_localuse_from_statistics.pl --confirm --verbose >16 - Each item changed reported, and the amounts, and the total items updated. >--- > .../update_localuse_from_statistics.pl | 43 ++++++++++++------- > 1 file changed, 28 insertions(+), 15 deletions(-) > >diff --git a/misc/maintenance/update_localuse_from_statistics.pl b/misc/maintenance/update_localuse_from_statistics.pl >index 7d64c645d1f..17820472764 100755 >--- a/misc/maintenance/update_localuse_from_statistics.pl >+++ b/misc/maintenance/update_localuse_from_statistics.pl >@@ -29,40 +29,47 @@ use Pod::Usage qw( pod2usage ); > > my ($params); > GetOptions( >- 'confirm' => \$params->{confirm}, 'help' => \$params->{help}, 'age:i' => \$params->{age}, >+ 'c|confirm' => \$params->{confirm}, >+ 'v|verbose' => \$params->{verbose}, >+ 'help' => \$params->{help}, > ); > if ( $params->{help} ) { > pod2usage( -verbose => 2 ); > exit; > } > >+my $updated; >+ >+if ( $params->{confirm} ) { >+ $updated = update_localuse( { verbose => $params->{verbose} } ); >+} >+ >+print "Updated $updated items.\n"; >+ > sub update_localuse { >+ my $params = shift; >+ my $verbose = $params->{verbose}; > > my $dbh = C4::Context->dbh; > >- my $items = Koha::Items->search(); >+ my $items = Koha::Items->search(); >+ my $updated = 0; > > # Loop through each item and update it with statistics info > while ( my $item = $items->next ) { > my $itemnumber = $item->itemnumber; > > my $localuse_count = Koha::Statistics->search( { itemnumber => $itemnumber, type => 'localuse' } )->count; >+ my $item_localuse = $item->localuse // 0; >+ next if $item_localuse == $localuse_count; > $item->localuse($localuse_count); >- $item->store; >+ $item->store( { skip_record_index => 1, skip_holds_queue => 1 } ); >+ $updated++; > >- print "Updated item $itemnumber with localuse statistics info.\n"; >+ print "Updated item $itemnumber with localuse statistics info. Was $item_localuse, now $localuse_count\n" >+ if $verbose; > } >-} >- >-my ($help); >-my $result = GetOptions( >- 'help|h' => \$help, >-); >- >-usage() if $help; >- >-if ( $params->{confirm} ) { >- update_localuse(); >+ return $updated; > } > > =head1 NAME >@@ -74,10 +81,12 @@ update_local_use_from_statistics.pl > update_localuse_from_statistics.pl > update_localuse_from_statistics.pl --help > update_localuse_from_statistics.pl --confirm >+ update_localuse_from_statistics.pl --verbose > > =head1 DESCRIPTION > > This script updates the items.localuse column with data from the statistics table to make sure the two tables are congruent. >+NOTE: If you have mapped the items.localuse field in your search engine you must reindex your records after running this script. > > =head1 OPTIONS > >@@ -91,6 +100,10 @@ Prints this help message > > Confirm to run the script. > >+=item B<-v|--verbose> >+ >+ Add verbosity to output. >+ > =back > > =cut >-- >2.39.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 37790
:
170902
|
170910