Bugzilla – Attachment 43693 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), 5.22 KB, created by
Jonathan Druart
on 2015-10-21 13:31:59 UTC
(
hide
)
Description:
Bug 13409 - Add ability to purge old special holidays using cleanup_database.pl
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2015-10-21 13:31:59 UTC
Size:
5.22 KB
patch
obsolete
>From 3dc041dfcd0aecfc8d9d1221d7f48f2da75fd478 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 > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > misc/cronjobs/cleanup_database.pl | 61 +++++++++++++++++++++++++++------------ > 1 file changed, 42 insertions(+), 19 deletions(-) > >diff --git a/misc/cronjobs/cleanup_database.pl b/misc/cronjobs/cleanup_database.pl >index 0766141..423b0ac 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 >@@ -71,6 +72,8 @@ Usage: $0 [-h|--help] [--sessions] [--sessdays DAYS] [-v|--verbose] [--zebraqueu > --all-restrictions purge all expired patrons restrictions. > --del-exp-selfreg Delete expired self registration accounts > --del-unv-selfreg DAYS Delete unverified self registrations older than DAYS >+ --holidays DAYS purge special holidays that passed more then DAYS days ago. >+ Defaults to 30 days of no days specified. > USAGE > exit $_[0]; > } >@@ -92,25 +95,27 @@ my ( > $allDebarments, > $pExpSelfReg, > $pUnvSelfReg, >+ $pHolidays, > ); > > GetOptions( >- 'h|help' => \$help, >- 'sessions' => \$sessions, >- 'sessdays:i' => \$sess_days, >- 'v|verbose' => \$verbose, >- 'm|mail:i' => \$mail, >- 'zebraqueue:i' => \$zebraqueue_days, >- 'merged' => \$purge_merged, >- 'import:i' => \$pImport, >- 'z3950' => \$pZ3950, >- 'logs:i' => \$pLogs, >- 'searchhistory:i' => \$pSearchhistory, >- 'list-invites:i' => \$pListShareInvites, >- 'restrictions:i' => \$pDebarments, >+ 'h|help' => \$help, >+ 'sessions' => \$sessions, >+ 'sessdays:i' => \$sess_days, >+ 'v|verbose' => \$verbose, >+ 'm|mail:i' => \$mail, >+ 'zebraqueue:i' => \$zebraqueue_days, >+ 'merged' => \$purge_merged, >+ 'import:i' => \$pImport, >+ 'z3950' => \$pZ3950, >+ 'logs:i' => \$pLogs, >+ 'searchhistory:i' => \$pSearchhistory, >+ 'list-invites:i' => \$pListShareInvites, >+ 'restrictions:i' => \$pDebarments, > 'all-restrictions' => \$allDebarments, >- 'del-exp-selfreg' => \$pExpSelfReg, >- 'del-unv-selfreg' => \$pUnvSelfReg, >+ 'del-exp-selfreg' => \$pExpSelfReg, >+ 'del-unv-selfreg' => \$pUnvSelfReg, >+ 'holidays:i' => \$pHolidays > ) || usage(1); > > # Use default values >@@ -122,6 +127,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); >@@ -140,6 +146,7 @@ unless ( $sessions > || $allDebarments > || $pExpSelfReg > || $pUnvSelfReg >+ || $pHolidays > ) { > print "You did not specify any cleanup work for the script to do.\n\n"; > usage(1); >@@ -266,17 +273,23 @@ if ($pDebarments) { > print "$count restrictions were deleted.\nDone with restrictions purge.\n" if $verbose; > } > >-if($allDebarments) { >+if ($allDebarments) { > print "All expired patrons restrictions purge triggered.\n" if $verbose; > $count = PurgeDebarments(0); > print "$count restrictions were deleted.\nDone with all restrictions purge.\n" if $verbose; > } > >-if( $pExpSelfReg ) { >+if ($pExpSelfReg) { > DeleteExpiredSelfRegs(); > } >-if( $pUnvSelfReg ) { >- DeleteUnverifiedSelfRegs( $pUnvSelfReg ); >+if ($pUnvSelfReg) { >+ DeleteUnverifiedSelfRegs($pUnvSelfReg); >+} >+ >+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); >@@ -376,3 +389,13 @@ sub DeleteUnverifiedSelfRegs { > my $cnt= C4::Members::DeleteUnverifiedOpacRegistrations( $_[0] ); > print "Removed $cnt unverified self-registrations\n" if $verbose; > } >+ >+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; >+} >-- >2.1.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 13409
:
34177
|
43588
|
43608
|
43609
|
43693
|
43694
|
43695