[Patches] [PATCH] 6094 Follow up for cleanup_database

koha-patchbot at kohaaloha.com koha-patchbot at kohaaloha.com
Fri Nov 4 19:52:22 NZDT 2011


From: Marcel de Rooy <m.de.rooy at rijksmuseum.nl>
Date: Thu, 20 Oct 2011 09:57:12 +0200
Subject: [PATCH] 6094 Follow up for cleanup_database
Content-Type: text/plain; charset="utf-8"

Adds purging completed entries from need_merge_authorities table.
If you set dontmerge to ON, you need to periodically remove records.
---
 misc/cronjobs/cleanup_database.pl |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/misc/cronjobs/cleanup_database.pl b/misc/cronjobs/cleanup_database.pl
index 1333111..2b0cf90 100755
--- a/misc/cronjobs/cleanup_database.pl
+++ b/misc/cronjobs/cleanup_database.pl
@@ -38,8 +38,8 @@ use Getopt::Long;
 
 sub usage {
     print STDERR <<USAGE;
-Usage: $0 [-h|--help] [--sessions] [--sessdays DAYS] [-v|--verbose] [--zebraqueue DAYS]
-        [-m|--mail]
+Usage: $0 [-h|--help] [--sessions] [--sessdays DAYS] [-v|--verbose] [--zebraqueue DAYS] [-m|--mail] [--merged]
+
    -h --help          prints this help message, and exits, ignoring all
                       other options
    --sessions         purge the sessions table.  If you use this while users 
@@ -50,11 +50,12 @@ Usage: $0 [-h|--help] [--sessions] [--sessdays DAYS] [-v|--verbose] [--zebraqueu
    --zebraqueue DAYS  purge completed entries from the zebraqueue from 
                       more than DAYS days ago.
    -m --mail          purge the mail queue. 
+   --merged           purged completed entries from need_merge_authorities.
 USAGE
     exit $_[0];
 }
 
-my ( $help, $sessions, $sess_days, $verbose, $zebraqueue_days, $mail );
+my ( $help, $sessions, $sess_days, $verbose, $zebraqueue_days, $mail, $purge_merged);
 
 GetOptions(
     'h|help'       => \$help,
@@ -63,13 +64,14 @@ GetOptions(
     'v|verbose'    => \$verbose,
     'm|mail'       => \$mail,
     'zebraqueue:i' => \$zebraqueue_days,
+    'merged'       => \$purge_merged,
 ) || usage(1);
 
 if ($help) {
     usage(0);
 }
 
-if ( !( $sessions || $zebraqueue_days || $mail ) ) {
+if ( !( $sessions || $zebraqueue_days || $mail || $purge_merged) ) {
     print "You did not specify any cleanup work for the script to do.\n\n";
     usage(1);
 }
@@ -134,6 +136,14 @@ if ($mail) {
     $sth->execute() or $dbh->errstr;
     print "Done with purging the mail queue.\n" if ($verbose);
 }
+
+if($purge_merged) {
+    print "Purging completed entries from need_merge_authorities.\n" if $verbose;
+    $sth = $dbh->prepare("DELETE FROM need_merge_authorities WHERE done=1");
+    $sth->execute() or die $dbh->errstr;
+    print "Done with purging need_merge_authorities.\n" if $verbose;
+}
+
 exit(0);
 
 sub RemoveOldSessions {
-- 
1.6.0.6




More information about the Patches mailing list