Bugzilla – Attachment 172779 Details for
Bug 26024
Purge undone of zebraqueue in cleanup_database.pl
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26024: Purge option for undone zebraq entries in cleanup_database.pl
Bug-26024-Purge-option-for-undone-zebraq-entries-i.patch (text/plain), 8.57 KB, created by
Peter Vashchuk
on 2024-10-15 14:30:16 UTC
(
hide
)
Description:
Bug 26024: Purge option for undone zebraq entries in cleanup_database.pl
Filename:
MIME Type:
Creator:
Peter Vashchuk
Created:
2024-10-15 14:30:16 UTC
Size:
8.57 KB
patch
obsolete
>From 87a18579c4d0ab15591e5daf3875dc5450086c95 Mon Sep 17 00:00:00 2001 >From: Petro Vashchuk <stalkernoid@gmail.com> >Date: Tue, 15 Oct 2024 17:27:43 +0300 >Subject: [PATCH] Bug 26024: Purge option for undone zebraq entries in > cleanup_database.pl > >Added --zebraqueue-undone DAYS option to cleanup_database.pl to purge uncompleted (done=0) zebraqueue entries older than DAYS days (90 days default). >--- > debian/koha-common.cron.daily | 2 +- > misc/cronjobs/cleanup_database.pl | 55 ++++++++++++++++++++++++------- > 2 files changed, 44 insertions(+), 13 deletions(-) > >diff --git a/debian/koha-common.cron.daily b/debian/koha-common.cron.daily >index 0d960ef0c5d..e518ed15ad5 100644 >--- a/debian/koha-common.cron.daily >+++ b/debian/koha-common.cron.daily >@@ -25,7 +25,7 @@ koha-foreach --chdir --enabled --email /usr/share/koha/bin/cronjobs/advance_noti > koha-foreach --chdir --enabled /usr/share/koha/bin/cronjobs/serialsUpdate.pl -c > koha-foreach --chdir --enabled /usr/share/koha/bin/cronjobs/membership_expiry.pl -c > koha-foreach --chdir --enabled /usr/share/koha/bin/cronjobs/holds/cancel_expired_holds.pl >/dev/null 2>&1 >-koha-foreach --chdir --enabled /usr/share/koha/bin/cronjobs/cleanup_database.pl --confirm --sessions --zebraqueue 10 --list-invites --temp-uploads --del-unv-selfreg 14 >+koha-foreach --chdir --enabled /usr/share/koha/bin/cronjobs/cleanup_database.pl --confirm --sessions --zebraqueue-undone 30 --zebraqueue 10 --list-invites --temp-uploads --del-unv-selfreg 14 > koha-foreach --chdir --enabled --noemail /usr/share/koha/bin/cronjobs/cleanup_database.pl --confirm --mail > koha-foreach --chdir --enabled /usr/share/koha/bin/cronjobs/holds/auto_unsuspend_holds.pl > /dev/null 2>&1 > koha-foreach --chdir --enabled /usr/share/koha/bin/cronjobs/merge_authorities.pl -b >diff --git a/misc/cronjobs/cleanup_database.pl b/misc/cronjobs/cleanup_database.pl >index 01930181294..ea25e7b37cf 100755 >--- a/misc/cronjobs/cleanup_database.pl >+++ b/misc/cronjobs/cleanup_database.pl >@@ -20,6 +20,7 @@ > use Modern::Perl; > > use constant DEFAULT_ZEBRAQ_PURGEDAYS => 30; >+use constant DEFAULT_ZEBRAQ_UNDONE_PURGEDAYS => 90; > use constant DEFAULT_MAIL_PURGEDAYS => 30; > use constant DEFAULT_IMPORT_PURGEDAYS => 60; > use constant DEFAULT_LOGS_PURGEDAYS => 180; >@@ -57,7 +58,7 @@ use Koha::UploadedFiles; > > sub usage { > print STDERR <<USAGE; >-Usage: $0 [-h|--help] [--confirm] [--sessions] [--sessdays DAYS] [-v|--verbose] [--zebraqueue DAYS] [-m|--mail] [--merged] [--import DAYS] [--logs DAYS] [--searchhistory DAYS] [--restrictions DAYS] [--all-restrictions] [--fees DAYS] [--temp-uploads] [--temp-uploads-days DAYS] [--uploads-missing 0|1 ] [--statistics DAYS] [--deleted-catalog DAYS] [--deleted-patrons DAYS] [--old-issues DAYS] [--old-reserves DAYS] [--transfers DAYS] [--labels DAYS] [--cards DAYS] [--bg-days DAYS [--bg-type TYPE] ] [--edifact-messages DAYS] >+Usage: $0 [-h|--help] [--confirm] [--sessions] [--sessdays DAYS] [-v|--verbose] [--zebraqueue DAYS] [--zebraqueue-undone DAYS] [-m|--mail] [--merged] [--import DAYS] [--logs DAYS] [--searchhistory DAYS] [--restrictions DAYS] [--all-restrictions] [--fees DAYS] [--temp-uploads] [--temp-uploads-days DAYS] [--uploads-missing 0|1 ] [--statistics DAYS] [--deleted-catalog DAYS] [--deleted-patrons DAYS] [--old-issues DAYS] [--old-reserves DAYS] [--transfers DAYS] [--labels DAYS] [--cards DAYS] [--bg-days DAYS [--bg-type TYPE] ] [--edifact-messages DAYS] > > -h --help prints this help message, and exits, ignoring all > other options >@@ -69,6 +70,8 @@ Usage: $0 [-h|--help] [--confirm] [--sessions] [--sessdays DAYS] [-v|--verbose] > about the run. > --zebraqueue DAYS purge completed zebraqueue entries older than DAYS days. > Defaults to 30 days if no days specified. >+ --zebraqueue-undone DAYS purge uncompleted zebraqueue entries older than DAYS days. >+ Defaults to 90 days if no days specified. > -m --mail DAYS purge items from the mail queue that are older than DAYS days. > Defaults to 30 days if no days specified. > --merged purged completed entries from need_merge_authorities. >@@ -135,6 +138,7 @@ my $sessions; > my $sess_days; > my $verbose; > my $zebraqueue_days; >+my $zebraqueue_days_undone; > my $mail; > my $purge_merged; > my $pImport; >@@ -182,6 +186,7 @@ GetOptions( > 'v|verbose' => \$verbose, > 'm|mail:i' => \$mail, > 'zebraqueue:i' => \$zebraqueue_days, >+ 'zebraqueue-undone:i' => \$zebraqueue_days_undone, > 'merged' => \$purge_merged, > 'import:i' => \$pImport, > 'z3950' => \$pZ3950, >@@ -221,17 +226,18 @@ GetOptions( > ) || usage(1); > > # Use default values >-$sessions = 1 if $sess_days && $sess_days > 0; >-$pImport = DEFAULT_IMPORT_PURGEDAYS if defined($pImport) && $pImport == 0; >-$pLogs = DEFAULT_LOGS_PURGEDAYS if defined($pLogs) && $pLogs == 0; >-$zebraqueue_days = DEFAULT_ZEBRAQ_PURGEDAYS if defined($zebraqueue_days) && $zebraqueue_days == 0; >-$mail = DEFAULT_MAIL_PURGEDAYS if defined($mail) && $mail == 0; >-$pSearchhistory = DEFAULT_SEARCHHISTORY_PURGEDAYS if defined($pSearchhistory) && $pSearchhistory == 0; >-$pDebarments = DEFAULT_DEBARMENTS_PURGEDAYS if defined($pDebarments) && $pDebarments == 0; >-$pMessages = DEFAULT_MESSAGES_PURGEDAYS if defined($pMessages) && $pMessages == 0; >-$jobs_days = DEFAULT_JOBS_PURGEDAYS if defined($jobs_days) && $jobs_days == 0; >-@jobs_types = (DEFAULT_JOBS_PURGETYPES) if $jobs_days && @jobs_types == 0; >-$edifact_msg_days = DEFAULT_EDIFACT_MSG_PURGEDAYS if defined($edifact_msg_days) && $edifact_msg_days == 0; >+$sessions = 1 if $sess_days && $sess_days > 0; >+$pImport = DEFAULT_IMPORT_PURGEDAYS if defined($pImport) && $pImport == 0; >+$pLogs = DEFAULT_LOGS_PURGEDAYS if defined($pLogs) && $pLogs == 0; >+$zebraqueue_days = DEFAULT_ZEBRAQ_PURGEDAYS if defined($zebraqueue_days) && $zebraqueue_days == 0; >+$zebraqueue_days_undone = DEFAULT_ZEBRAQ_UNDONE_PURGEDAYS if defined($zebraqueue_days_undone) && $zebraqueue_days_undone == 0; >+$mail = DEFAULT_MAIL_PURGEDAYS if defined($mail) && $mail == 0; >+$pSearchhistory = DEFAULT_SEARCHHISTORY_PURGEDAYS if defined($pSearchhistory) && $pSearchhistory == 0; >+$pDebarments = DEFAULT_DEBARMENTS_PURGEDAYS if defined($pDebarments) && $pDebarments == 0; >+$pMessages = DEFAULT_MESSAGES_PURGEDAYS if defined($pMessages) && $pMessages == 0; >+$jobs_days = DEFAULT_JOBS_PURGEDAYS if defined($jobs_days) && $jobs_days == 0; >+@jobs_types = (DEFAULT_JOBS_PURGETYPES) if $jobs_days && @jobs_types == 0; >+$edifact_msg_days = DEFAULT_EDIFACT_MSG_PURGEDAYS if defined($edifact_msg_days) && $edifact_msg_days == 0; > > # Choose the number of days at which to purge unaccepted list invites: > # - DAYS defined in the list-invites parameter is prioritised first >@@ -251,6 +257,7 @@ if ($help) { > > unless ( $sessions > || $zebraqueue_days >+ || $zebraqueue_days_undone > || $mail > || $purge_merged > || $pImport >@@ -347,6 +354,30 @@ if ($zebraqueue_days) { > } > } > >+if ($zebraqueue_days_undone) { >+ my $count = 0; >+ print "Zebraqueue undone purge triggered for $zebraqueue_days_undone days.\n" if $verbose; >+ $sth = $dbh->prepare( >+ q{ >+ SELECT id,biblio_auth_number,server,time >+ FROM zebraqueue >+ WHERE done=0 AND time < date_sub(curdate(), INTERVAL ? DAY) >+ } >+ ); >+ $sth->execute($zebraqueue_days_undone) or die $dbh->errstr; >+ $sth2 = $dbh->prepare(q{ DELETE FROM zebraqueue WHERE id=? }); >+ while ( my $record = $sth->fetchrow_hashref ) { >+ if ($confirm) { >+ $sth2->execute( $record->{id} ) or die $dbh->errstr; >+ } >+ $count++; >+ } >+ if ($verbose) { >+ say $confirm ? "$count records were deleted." : "$count records would have been deleted."; >+ say "Done with zebraqueue undone purge."; >+ } >+} >+ > if ($mail) { > my $count = 0; > print "Mail queue purge triggered for $mail days.\n" if $verbose; >-- >2.46.0
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 26024
:
107083
| 172779