Bugzilla – Attachment 34177 Details for
Bug 13409
Add ability to purge old special holidays using cleanup_database.pl
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 13409 - Add ability to purge old special holidays using cleanup_database.pl
Bug-13409---Add-ability-to-purge-old-special-holid.patch (text/plain), 3.90 KB, created by
Kyle M Hall
on 2014-12-08 15:34:16 UTC
(
hide
)
Description:
Bug 13409 - Add ability to purge old special holidays using cleanup_database.pl
Filename:
MIME Type:
Creator:
Kyle M Hall
Created:
2014-12-08 15:34:16 UTC
Size:
3.90 KB
patch
obsolete
>From 1073f889e4d51b43cb1f592535b05488e65b36e5 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Mon, 8 Dec 2014 09:21:12 -0500 >Subject: [PATCH] Bug 13409 - Add ability to purge old special holidays using cleanup_database.pl > >Some libraries have expressed interested in being able to purge old >holidays from the database. > >Test Plan: >1) Create some special holidays in the past >2) Use the new --holidays DAYS option to test deleting special holidays >3) Verify only special holidays past the given amount of days were deleted >--- > misc/cronjobs/cleanup_database.pl | 30 ++++++++++++++++++++++++++---- > 1 files changed, 26 insertions(+), 4 deletions(-) > >diff --git a/misc/cronjobs/cleanup_database.pl b/misc/cronjobs/cleanup_database.pl >index 57a5401..bdecb3b 100755 >--- a/misc/cronjobs/cleanup_database.pl >+++ b/misc/cronjobs/cleanup_database.pl >@@ -26,6 +26,7 @@ use constant DEFAULT_LOGS_PURGEDAYS => 180; > use constant DEFAULT_SEARCHHISTORY_PURGEDAYS => 30; > use constant DEFAULT_SHARE_INVITATION_EXPIRY_DAYS => 14; > use constant DEFAULT_DEBARMENTS_PURGEDAYS => 30; >+use constant DEFAULT_HOLIDAYS_PURGEDAYS => 30; > > BEGIN { > # find Koha's Perl modules >@@ -69,14 +70,16 @@ Usage: $0 [-h|--help] [--sessions] [--sessdays DAYS] [-v|--verbose] [--zebraqueu > days. Defaults to 14 days if no days specified. > --restrictions DAYS purge patrons restrictions expired since more than DAYS days. > Defaults to 30 days if no days specified. >+ --holidays=DAYS purge special holidays that passed more then DAYS days ago. >+ Defaults to 30 days of no days specified. > USAGE > exit $_[0]; > } > > my ( >- $help, $sessions, $sess_days, $verbose, $zebraqueue_days, >- $mail, $purge_merged, $pImport, $pLogs, $pSearchhistory, >- $pZ3950, $pListShareInvites, $pDebarments, >+ $help, $sessions, $sess_days, $verbose, $zebraqueue_days, >+ $mail, $purge_merged, $pImport, $pLogs, $pSearchhistory, >+ $pZ3950, $pListShareInvites, $pDebarments, $pHolidays, > ); > > GetOptions( >@@ -93,6 +96,7 @@ GetOptions( > 'searchhistory:i' => \$pSearchhistory, > 'list-invites:i' => \$pListShareInvites, > 'restrictions:i' => \$pDebarments, >+ 'holidays:i' => \$pHolidays > ) || usage(1); > > # Use default values >@@ -104,6 +108,7 @@ $mail = DEFAULT_MAIL_PURGEDAYS if defined($mail) > $pSearchhistory = DEFAULT_SEARCHHISTORY_PURGEDAYS if defined($pSearchhistory) && $pSearchhistory == 0; > $pListShareInvites = DEFAULT_SHARE_INVITATION_EXPIRY_DAYS if defined($pListShareInvites) && $pListShareInvites == 0; > $pDebarments = DEFAULT_DEBARMENTS_PURGEDAYS if defined($pDebarments) && $pDebarments == 0; >+$pHolidays = DEFAULT_HOLIDAYS_PURGEDAYS if defined($pHolidays) && $pHolidays == 0; > > if ($help) { > usage(0); >@@ -118,7 +123,8 @@ unless ( $sessions > || $pSearchhistory > || $pZ3950 > || $pListShareInvites >- || $pDebarments ) >+ || $pDebarments >+ || $pHolidays ) > { > print "You did not specify any cleanup work for the script to do.\n\n"; > usage(1); >@@ -238,6 +244,12 @@ if ($pDebarments) { > print "$count restrictions were deleted.\nDone with restrictions purge.\n" if $verbose; > } > >+if ($pHolidays) { >+ print "Passed special holidays purge triggered for $pHolidays days.\n" if $verbose; >+ PurgeHolidays(); >+ print "Done with holidays purge.\n" if $verbose; >+} >+ > exit(0); > > sub RemoveOldSessions { >@@ -324,3 +336,13 @@ sub PurgeDebarments { > } > return $count; > } >+ >+sub PurgeHolidays { >+ $sth = $dbh->prepare( >+ q{ >+ DELETE FROM special_holidays >+ WHERE DATE( CONCAT( year, '-', month, '-', day ) ) < DATE_SUB( CURDATE(), INTERVAL ? DAY ) >+ } >+ ); >+ $sth->execute( $pHolidays ) or die $dbh->errstr; >+} >-- >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 13409
:
34177
|
43588
|
43608
|
43609
|
43693
|
43694
|
43695