Bugzilla – Attachment 52081 Details for
Bug 16672
Add ability to remove expired holidays from special_holidays
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 16672 - Add ability to remove expired holidays from special_holidays
Bug-16672---Add-ability-to-remove-expired-holidays.patch (text/plain), 4.19 KB, created by
Kyle M Hall (khall)
on 2016-06-06 13:55:14 UTC
(
hide
)
Description:
Bug 16672 - Add ability to remove expired holidays from special_holidays
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2016-06-06 13:55:14 UTC
Size:
4.19 KB
patch
obsolete
>From 9b56f1ccafe513eb5673ec7a92db5a109c71b7f7 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Mon, 6 Jun 2016 13:52:45 +0000 >Subject: [PATCH] Bug 16672 - Add ability to remove expired holidays from > special_holidays > >It would be very helpful if the cleanup_database.pl script had the >ability to delete holidays from the special_holidays table there were >older than a given number of days in the past. > >Test Plan: >1) Apply this patch >2) Create some unique holidays in the past of varying ages >3) Test the new switch '--unique-holidays DAYS' for cleanup_database.pl >4) Verify only holidays older then the specified number of days are removed > >NOTE: The language 'unique holdays' is used in the interface to match > it's use in the staff web interface. >--- > misc/cronjobs/cleanup_database.pl | 55 ++++++++++++++++++++++++++------------- > 1 file changed, 37 insertions(+), 18 deletions(-) > >diff --git a/misc/cronjobs/cleanup_database.pl b/misc/cronjobs/cleanup_database.pl >index bb54256..d9004ef 100755 >--- a/misc/cronjobs/cleanup_database.pl >+++ b/misc/cronjobs/cleanup_database.pl >@@ -78,7 +78,8 @@ Usage: $0 [-h|--help] [--sessions] [--sessdays DAYS] [-v|--verbose] [--zebraqueu > Defaults to 30 days if no days specified. > --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 >+ --del-unv-selfreg DAYS Delete unverified self registrations older than DAYS >+ --unique-holidays DAYS Delete all unique holidays older than DAYS > USAGE > exit $_[0]; > } >@@ -100,25 +101,27 @@ my $allDebarments; > my $pExpSelfReg; > my $pUnvSelfReg; > my $fees_days; >+my $special_holidays_days; > > 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, >- 'fees:i' => \$fees_days, >- 'searchhistory:i' => \$pSearchhistory, >- 'list-invites:i' => \$pListShareInvites, >- 'restrictions:i' => \$pDebarments, >- 'all-restrictions' => \$allDebarments, >- 'del-exp-selfreg' => \$pExpSelfReg, >- 'del-unv-selfreg' => \$pUnvSelfReg, >+ '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, >+ 'fees:i' => \$fees_days, >+ 'searchhistory:i' => \$pSearchhistory, >+ 'list-invites:i' => \$pListShareInvites, >+ 'restrictions:i' => \$pDebarments, >+ 'all-restrictions' => \$allDebarments, >+ 'del-exp-selfreg' => \$pExpSelfReg, >+ 'del-unv-selfreg' => \$pUnvSelfReg, >+ 'unique-holidays:i' => \$special_holidays_days, > ) || usage(1); > > # Use default values >@@ -149,6 +152,7 @@ unless ( $sessions > || $allDebarments > || $pExpSelfReg > || $pUnvSelfReg >+ || $special_holidays_days > ) { > print "You did not specify any cleanup work for the script to do.\n\n"; > usage(1); >@@ -294,6 +298,10 @@ if( $pUnvSelfReg ) { > DeleteUnverifiedSelfRegs( $pUnvSelfReg ); > } > >+if ($special_holidays_days) { >+ DeleteSpecialHolidays($special_holidays_days); >+} >+ > exit(0); > > sub RemoveOldSessions { >@@ -391,3 +399,14 @@ sub DeleteUnverifiedSelfRegs { > my $cnt= C4::Members::DeleteUnverifiedOpacRegistrations( $_[0] ); > print "Removed $cnt unverified self-registrations\n" if $verbose; > } >+ >+sub DeleteSpecialHolidays { >+ my ( $days ) = @_; >+ >+ my $sth = $dbh->prepare(q{ >+ DELETE FROM special_holidays >+ WHERE DATE( CONCAT( year, '-', month, '-', day ) ) < DATE_SUB( CAST(NOW() AS DATE), INTERVAL ? DAY ); >+ }); >+ my $count = $sth->execute( $days ) + 0; >+ print "Removed $count unqiue holidays\n" if $verbose; >+} >-- >2.1.4
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 16672
:
52081
|
52342
|
52353
|
52354
|
52355