Bugzilla – Attachment 41043 Details for
Bug 14402
Add --fees option to cleanup_database.pl to purge all 0 balance fees and payments older than the given number of days
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Add --fees option to cleanup_database.pl
Add---fees-option-to-cleanupdatabasepl.patch (text/plain), 3.36 KB, created by
Barton Chittenden
on 2015-07-16 19:29:26 UTC
(
hide
)
Description:
Add --fees option to cleanup_database.pl
Filename:
MIME Type:
Creator:
Barton Chittenden
Created:
2015-07-16 19:29:26 UTC
Size:
3.36 KB
patch
obsolete
>From 35e55854d4c5e51b5bebcd0da4a4134178e7f43a Mon Sep 17 00:00:00 2001 >From: Barton Chittenden <barton@bywatersolutions.com> >Date: Thu, 16 Jul 2015 12:25:08 -0700 >Subject: [PATCH] Add --fees option to cleanup_database.pl > >http://bugs.koha-community.org/show_bug.cgi?id=14402 >--- > misc/cronjobs/cleanup_database.pl | 27 ++++++++++++++++++++++++++- > 1 file changed, 26 insertions(+), 1 deletion(-) > >diff --git a/misc/cronjobs/cleanup_database.pl b/misc/cronjobs/cleanup_database.pl >index cd92dc4..8797915 100755 >--- a/misc/cronjobs/cleanup_database.pl >+++ b/misc/cronjobs/cleanup_database.pl >@@ -42,7 +42,7 @@ use C4::Log; > > 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] [--all-restrictions] >+Usage: $0 [-h|--help] [--sessions] [--sessdays DAYS] [-v|--verbose] [--zebraqueue DAYS] [-m|--mail] [--merged] [--import DAYS] [--logs DAYS] [--searchhistory DAYS] [--restrictions DAYS] [--all-restrictions] [--fees DAYS] > > -h --help prints this help message, and exits, ignoring all > other options >@@ -60,6 +60,8 @@ Usage: $0 [-h|--help] [--sessions] [--sessdays DAYS] [-v|--verbose] [--zebraqueu > Defaults to 60 days if no days specified. > --z3950 purge records from import tables that are the result > of Z39.50 searches >+ --fees DAYS purge entries accountlines older than DAYS days, where >+ amountoutstanding is 0. > --logs DAYS purge entries from action_logs older than DAYS days. > Defaults to 180 days if no days specified. > --searchhistory DAYS purge entries from search_history older than DAYS days. >@@ -77,6 +79,7 @@ my ( > $help, $sessions, $sess_days, $verbose, $zebraqueue_days, > $mail, $purge_merged, $pImport, $pLogs, $pSearchhistory, > $pZ3950, $pListShareInvites, $pDebarments, $allDebarments, >+ $fees_days > ); > > GetOptions( >@@ -90,6 +93,7 @@ GetOptions( > 'import:i' => \$pImport, > 'z3950' => \$pZ3950, > 'logs:i' => \$pLogs, >+ 'fees:i' => \$fees_days, > 'searchhistory:i' => \$pSearchhistory, > 'list-invites:i' => \$pListShareInvites, > 'restrictions:i' => \$pDebarments, >@@ -116,6 +120,7 @@ unless ( $sessions > || $purge_merged > || $pImport > || $pLogs >+ || $fees_days > || $pSearchhistory > || $pZ3950 > || $pListShareInvites >@@ -222,6 +227,12 @@ if ($pLogs) { > print "Done with purging action_logs.\n" if $verbose; > } > >+if ($fees_days) { >+ print "Purging records from accountlines.\n" if $verbose; >+ PurgeFees( $fees_days ); >+ print "Done purging records from accountlines.\n" if $verbose; >+} >+ > if ($pSearchhistory) { > print "Purging records older than $pSearchhistory from search_history.\n" if $verbose; > PurgeSearchHistory($pSearchhistory); >@@ -340,3 +351,17 @@ sub PurgeDebarments { > } > return $count; > } >+ >+sub PurgeFees { >+ my $days = shift; >+ my $count = 0; >+ >+ $sth = $dbh->prepare( >+ q{ >+ DELETE FROM accountlines >+ WHERE date < date_sub(curdate(), INTERVAL ? DAY) >+ AND amountoutstanding = 0; >+ } >+ ); >+ $sth->execute($days) or die $dbh->errstr; >+} >-- >1.7.10.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 14402
:
41043
|
41086
|
41087
|
41088
|
42242
|
42243
|
42244
|
42245
|
42246
|
42477
|
42478
|
42479
|
42480
|
42556
|
42557
|
42815
|
42816
|
42817
|
42818
|
42819
|
42820
|
42993
|
42994
|
42995
|
42996
|
42997
|
44664