Bugzilla – Attachment 37312 Details for
Bug 13166
add all restrictions purge to cleanup_database.pl
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[PASSED QA] Bug 13166 - add all restrictions purge to cleanup_database.pl
PASSED-QA-Bug-13166---add-all-restrictions-purge-t.patch (text/plain), 4.89 KB, created by
Kyle M Hall (khall)
on 2015-03-27 12:47:23 UTC
(
hide
)
Description:
[PASSED QA] Bug 13166 - add all restrictions purge to cleanup_database.pl
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2015-03-27 12:47:23 UTC
Size:
4.89 KB
patch
obsolete
>From 92dab7ee6cbb4e35bf61f432fe7932db3c09910e Mon Sep 17 00:00:00 2001 >From: Fridolin Somers <fridolin.somers@biblibre.com> >Date: Thu, 30 Oct 2014 11:59:28 +0100 >Subject: [PATCH] [PASSED QA] Bug 13166 - add all restrictions purge to cleanup_database.pl > >Bug 12760 adds the ability to purge expired restrictions older than some days. > >But if you want to purge all expired restrictions, using "--restrictions 0" does not work, it's like "--restrictions" so it uses default purge days. > >This patch adds a new option "--all-restrictions" to purge all expired restrictions. > >Test plan : >- Select a borrower >- Create a restriction with expiration date in the futur >- Create a restriction expired since 1 day >- Create a restriction expired since 10 days >- run without argument "misc/cronjobs/cleanup_database.pl" >=> You see help text for --all-restrictions option >- run "misc/cronjobs/cleanup_database.pl -v --restrictions --all-restrictions" >=> You get the message : You can not specify both --restrictions and --all-restrictions >- run "misc/cronjobs/cleanup_database.pl -v --restrictions 30" >=> no restriction is removed >- run "misc/cronjobs/cleanup_database.pl -v --restrictions 9" >=> restriction expired since 10 days is removed >- run "misc/cronjobs/cleanup_database.pl -v --all-restrictions" >=> restriction expired since 1 day is removed > >Signed-off-by: Larry Baerveldt <larry@bywatersolutions.com> > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > misc/cronjobs/cleanup_database.pl | 25 ++++++++++++++++++++----- > 1 files changed, 20 insertions(+), 5 deletions(-) > >diff --git a/misc/cronjobs/cleanup_database.pl b/misc/cronjobs/cleanup_database.pl >index 57a5401..2dc3f2e 100755 >--- a/misc/cronjobs/cleanup_database.pl >+++ b/misc/cronjobs/cleanup_database.pl >@@ -43,7 +43,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] [--restrictions DAYS] >+Usage: $0 [-h|--help] [--sessions] [--sessdays DAYS] [-v|--verbose] [--zebraqueue DAYS] [-m|--mail] [--merged] [--import DAYS] [--logs DAYS] [--searchhistory DAYS] [--restrictions DAYS] [--all-restrictions] > > -h --help prints this help message, and exits, ignoring all > other options >@@ -69,6 +69,7 @@ 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. >+ --all-restrictions purge all expired patrons restrictions. > USAGE > exit $_[0]; > } >@@ -76,7 +77,7 @@ USAGE > my ( > $help, $sessions, $sess_days, $verbose, $zebraqueue_days, > $mail, $purge_merged, $pImport, $pLogs, $pSearchhistory, >- $pZ3950, $pListShareInvites, $pDebarments, >+ $pZ3950, $pListShareInvites, $pDebarments, $allDebarments, > ); > > GetOptions( >@@ -93,6 +94,7 @@ GetOptions( > 'searchhistory:i' => \$pSearchhistory, > 'list-invites:i' => \$pListShareInvites, > 'restrictions:i' => \$pDebarments, >+ 'all-restrictions' => \$allDebarments, > ) || usage(1); > > # Use default values >@@ -118,12 +120,18 @@ unless ( $sessions > || $pSearchhistory > || $pZ3950 > || $pListShareInvites >- || $pDebarments ) >+ || $pDebarments >+ || $allDebarments ) > { > print "You did not specify any cleanup work for the script to do.\n\n"; > usage(1); > } > >+if ($pDebarments && $allDebarments) { >+ print "You can not specify both --restrictions and --all-restrictions.\n\n"; >+ usage(1); >+} >+ > my $dbh = C4::Context->dbh(); > my $sth; > my $sth2; >@@ -234,10 +242,16 @@ if ($pListShareInvites) { > > if ($pDebarments) { > print "Expired patrons restrictions purge triggered for $pDebarments days.\n" if $verbose; >- $count = PurgeDebarments(); >+ $count = PurgeDebarments($pDebarments); > print "$count restrictions were deleted.\nDone with restrictions purge.\n" if $verbose; > } > >+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; >+} >+ > exit(0); > > sub RemoveOldSessions { >@@ -309,6 +323,7 @@ sub PurgeZ3950 { > > sub PurgeDebarments { > require Koha::Borrower::Debarments; >+ my $days = shift; > $count = 0; > $sth = $dbh->prepare( > q{ >@@ -317,7 +332,7 @@ sub PurgeDebarments { > WHERE expiration < date_sub(curdate(), INTERVAL ? DAY) > } > ); >- $sth->execute($pDebarments) or die $dbh->errstr; >+ $sth->execute($days) or die $dbh->errstr; > while ( my ($borrower_debarment_id) = $sth->fetchrow_array ) { > Koha::Borrower::Debarments::DelDebarment($borrower_debarment_id); > $count++; >-- >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 13166
:
32968
|
32971
|
36673
| 37312