Bugzilla – Attachment 18424 Details for
Bug 10361
Add Option to cleanup_database.pl to purge search_history entries
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 10361 - Add Option to cleanup_database.pl to purge search_history entries
Bug-10361---Add-Option-to-cleanupdatabasepl-to-pur.patch (text/plain), 5.76 KB, created by
Mirko Tietgen
on 2013-05-28 12:37:40 UTC
(
hide
)
Description:
Bug 10361 - Add Option to cleanup_database.pl to purge search_history entries
Filename:
MIME Type:
Creator:
Mirko Tietgen
Created:
2013-05-28 12:37:40 UTC
Size:
5.76 KB
patch
obsolete
>From a90afe2fd1cb2709612eded667873d18aedf9b6c Mon Sep 17 00:00:00 2001 >From: Mirko Tietgen <mirko@abunchofthings.net> >Date: Tue, 28 May 2013 14:33:59 +0200 >Subject: [PATCH] Bug 10361 - Add Option to cleanup_database.pl to purge search_history entries > >Add an option to cleanup_database.pl to purge the search_history entries older than X days. >--- > misc/cronjobs/cleanup_database.pl | 70 +++++++++++++++++++++--------------- > 1 files changed, 41 insertions(+), 29 deletions(-) > >diff --git a/misc/cronjobs/cleanup_database.pl b/misc/cronjobs/cleanup_database.pl >index 99310df..68bea48 100755 >--- a/misc/cronjobs/cleanup_database.pl >+++ b/misc/cronjobs/cleanup_database.pl >@@ -23,6 +23,7 @@ use warnings; > use constant DEFAULT_ZEBRAQ_PURGEDAYS => 30; > use constant DEFAULT_IMPORT_PURGEDAYS => 60; > use constant DEFAULT_LOGS_PURGEDAYS => 180; >+use constant DEFAULT_SEARCHHISTORY_PURGEDAYS => 30; > > BEGIN { > # find Koha's Perl modules >@@ -38,53 +39,57 @@ use Getopt::Long; > > sub usage { > print STDERR <<USAGE; >-Usage: $0 [-h|--help] [--sessions] [--sessdays DAYS] [-v|--verbose] [--zebraqueue DAYS] [-m|--mail] [--merged] [--import DAYS] [--logs DAYS] >- >- -h --help prints this help message, and exits, ignoring all >- other options >- --sessions purge the sessions table. If you use this while users >- are logged into Koha, they will have to reconnect. >- --sessdays DAYS purge only sessions older than DAYS days. >- -v --verbose will cause the script to give you a bit more information >- about the run. >- --zebraqueue DAYS purge completed zebraqueue entries older than DAYS days. >- Defaults to 30 days if no days specified. >- -m --mail purge the mail queue. >- --merged purged completed entries from need_merge_authorities. >- --import DAYS purge records from import tables older than DAYS days. >- Defaults to 60 days if no days specified. >- --logs DAYS purge entries from action_logs older than DAYS days. >- Defaults to 180 days if no days specified. >+Usage: $0 [-h|--help] [--sessions] [--sessdays DAYS] [-v|--verbose] [--zebraqueue DAYS] [-m|--mail] [--merged] [--import DAYS] [--logs DAYS] [--searchhistory DAYS] >+ >+ -h --help prints this help message, and exits, ignoring all >+ other options >+ --sessions purge the sessions table. If you use this while users >+ are logged into Koha, they will have to reconnect. >+ --sessdays DAYS purge only sessions older than DAYS days. >+ -v --verbose will cause the script to give you a bit more information >+ about the run. >+ --zebraqueue DAYS purge completed zebraqueue entries older than DAYS days. >+ Defaults to 30 days if no days specified. >+ -m --mail purge the mail queue. >+ --merged purged completed entries from need_merge_authorities. >+ --import DAYS purge records from import tables older than DAYS days. >+ Defaults to 60 days if no days specified. >+ --logs DAYS purge entries from action_logs older than DAYS days. >+ Defaults to 180 days if no days specified. >+ --searchhistory DAYS purge entries from search_history older than DAYS days. >+ Defaults to 30 days if no days specified > USAGE > exit $_[0]; > } > >-my ( $help, $sessions, $sess_days, $verbose, $zebraqueue_days, $mail, $purge_merged, $pImport, $pLogs); >+my ( $help, $sessions, $sess_days, $verbose, $zebraqueue_days, $mail, $purge_merged, $pImport, $pLogs, $pSearchhistory); > > GetOptions( >- 'h|help' => \$help, >- 'sessions' => \$sessions, >- 'sessdays:i' => \$sess_days, >- 'v|verbose' => \$verbose, >- 'm|mail' => \$mail, >- 'zebraqueue:i' => \$zebraqueue_days, >- 'merged' => \$purge_merged, >- 'import:i' => \$pImport, >- 'logs:i' => \$pLogs, >+ 'h|help' => \$help, >+ 'sessions' => \$sessions, >+ 'sessdays:i' => \$sess_days, >+ 'v|verbose' => \$verbose, >+ 'm|mail' => \$mail, >+ 'zebraqueue:i' => \$zebraqueue_days, >+ 'merged' => \$purge_merged, >+ 'import:i' => \$pImport, >+ 'logs:i' => \$pLogs, >+ 'searchhistory:i' => \$pSearchhistory, > ) || usage(1); > > $sessions=1 if $sess_days && $sess_days>0; >-# if --import, --logs or --zebraqueue were passed without number of days, >+# if --import, --logs, --zebraqueue or --searchhistory were passed without number of days, > # use defaults > $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; >+$pSearchhistory= DEFAULT_SEARCHHISTORY_PURGEDAYS if defined($pSearchhistory) && $pSearchhistory==0; > > if ($help) { > usage(0); > } > >-if ( !( $sessions || $zebraqueue_days || $mail || $purge_merged || $pImport || $pLogs) ) { >+if ( !( $sessions || $zebraqueue_days || $mail || $purge_merged || $pImport || $pLogs || $pSearchhistory ) ) { > print "You did not specify any cleanup work for the script to do.\n\n"; > usage(1); > } >@@ -170,6 +175,13 @@ if($pLogs) { > print "Done with purging action_logs.\n" if $verbose; > } > >+if($pSearchhistory) { >+ print "Purging records older than $pSearchhistory from search_history.\n" if $verbose; >+ $sth = $dbh->prepare("DELETE FROM search_history WHERE time < DATE_SUB( NOW(), INTERVAL ? DAY )"); >+ $sth->execute($pSearchhistory) or die $dbh->errstr; >+ print "Done with purging search_history.\n" if $verbose; >+} >+ > exit(0); > > sub RemoveOldSessions { >-- >1.7.2.5
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 10361
:
18424
|
18838
|
18839
|
20067
|
20068
|
20069
|
20258
|
20740
|
20741