Bugzilla – Attachment 30813 Details for
Bug 12760
add restrictions purge to cleanup_database.pl
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12760 - add restrictions purge to cleanup_database.pl
Bug-12760---add-restrictions-purge-to-cleanupdatab.patch (text/plain), 5.00 KB, created by
Chris Cormack
on 2014-08-15 02:36:54 UTC
(
hide
)
Description:
Bug 12760 - add restrictions purge to cleanup_database.pl
Filename:
MIME Type:
Creator:
Chris Cormack
Created:
2014-08-15 02:36:54 UTC
Size:
5.00 KB
patch
obsolete
>From 72f71b035ca6f50e4dea3838e8c9b1e047d93833 Mon Sep 17 00:00:00 2001 >From: Fridolin Somers <fridolin.somers@biblibre.com> >Date: Thu, 14 Aug 2014 14:56:26 +0200 >Subject: [PATCH] Bug 12760 - add restrictions purge to cleanup_database.pl > >This patch adds to the database cleanup script an option to purge expired patron restrictions (debarments in code). > >Test plan : >- Select a borrower >- Create a restriction with expiration date in the futur >- Create a restriction expired since 7 days >- Create a restriction expired since 14 days >- run "misc/cronjobs/cleanup_database.pl -v --restrictions 14" >=> no restriction is removed for this borrower >- run "misc/cronjobs/cleanup_database.pl -v --restrictions 13" >=> restriction expired since 14 days is removed >- run "misc/cronjobs/cleanup_database.pl -v --restrictions 6" >=> restriction expired since 7 days is removed >- run without argument "misc/cronjobs/cleanup_database.pl" >=> You see help text for restrictions option >- run without days "misc/cronjobs/cleanup_database.pl -v --restrictions" >=> You get a purge on 30 days > >Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> >--- > misc/cronjobs/cleanup_database.pl | 32 +++++++++++++++++++++++++++++--- > 1 file changed, 29 insertions(+), 3 deletions(-) > >diff --git a/misc/cronjobs/cleanup_database.pl b/misc/cronjobs/cleanup_database.pl >index fa27e9b..49c0157 100755 >--- a/misc/cronjobs/cleanup_database.pl >+++ b/misc/cronjobs/cleanup_database.pl >@@ -26,6 +26,7 @@ use constant DEFAULT_IMPORT_PURGEDAYS => 60; > 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; > > BEGIN { > # find Koha's Perl modules >@@ -43,7 +44,7 @@ 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] [--searchhistory DAYS] >+Usage: $0 [-h|--help] [--sessions] [--sessdays DAYS] [-v|--verbose] [--zebraqueue DAYS] [-m|--mail] [--merged] [--import DAYS] [--logs DAYS] [--searchhistory DAYS] [--restrictions DAYS] > > -h --help prints this help message, and exits, ignoring all > other options >@@ -67,6 +68,8 @@ Usage: $0 [-h|--help] [--sessions] [--sessdays DAYS] [-v|--verbose] [--zebraqueu > Defaults to 30 days if no days specified > --list-invites DAYS purge (unaccepted) list share invites older than DAYS > 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. > USAGE > exit $_[0]; > } >@@ -75,7 +78,7 @@ my ( > $help, $sessions, $sess_days, $verbose, > $zebraqueue_days, $mail, $purge_merged, $pImport, > $pLogs, $pSearchhistory, $pZ3950, >- $pListShareInvites, >+ $pListShareInvites, $pDebarments, > ); > > GetOptions( >@@ -91,6 +94,7 @@ GetOptions( > 'logs:i' => \$pLogs, > 'searchhistory:i' => \$pSearchhistory, > 'list-invites:i' => \$pListShareInvites, >+ 'restrictions:i' => \$pDebarments, > ) || usage(1); > > $sessions=1 if $sess_days && $sess_days>0; >@@ -102,6 +106,7 @@ $zebraqueue_days= DEFAULT_ZEBRAQ_PURGEDAYS if defined($zebraqueue_days) && $zebr > $mail= DEFAULT_MAIL_PURGEDAYS if defined($mail) && $mail==0; > $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; > > if ($help) { > usage(0); >@@ -115,7 +120,8 @@ unless ( $sessions > || $pLogs > || $pSearchhistory > || $pZ3950 >- || $pListShareInvites ) >+ || $pListShareInvites >+ || $pDebarments ) > { > print "You did not specify any cleanup work for the script to do.\n\n"; > usage(1); >@@ -224,6 +230,12 @@ if ($pListShareInvites) { > print "Done with purging unaccepted list share invites.\n" if $verbose; > } > >+if($pDebarments) { >+ print "Expired patrons restrictions purge triggered for $pDebarments days.\n" if $verbose; >+ $count = PurgeDebarments(); >+ print "$count restrictions were deleted.\nDone with restrictions purge.\n" if $verbose; >+} >+ > exit(0); > > sub RemoveOldSessions { >@@ -279,3 +291,17 @@ sub PurgeZ3950 { > }); > $sth->execute() or die $dbh->errstr; > } >+ >+sub PurgeDebarments { >+ require Koha::Borrower::Debarments; >+ $count = 0; >+ $sth = $dbh->prepare(q{ >+ SELECT borrower_debarment_id FROM borrower_debarments WHERE expiration < date_sub(curdate(), INTERVAL ? DAY) >+ }); >+ $sth->execute($pDebarments) or die $dbh->errstr; >+ while ( my ($borrower_debarment_id) = $sth->fetchrow_array ) { >+ Koha::Borrower::Debarments::DelDebarment($borrower_debarment_id); >+ $count++; >+ } >+ return $count; >+} >-- >1.9.1
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 12760
:
30786
|
30788
|
30789
|
30813
|
30814
|
30815
|
30832
|
30833
|
30834