@@ -, +, @@ cleanup_database --- misc/cronjobs/cleanup_database.pl | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) --- a/misc/cronjobs/cleanup_database.pl +++ a/misc/cronjobs/cleanup_database.pl @@ -91,6 +91,7 @@ Usage: $0 [-h|--help] [--sessions] [--sessdays DAYS] [-v|--verbose] [--zebraqueu --old-reserves DAYS Purge reserves (old_reserves) more than DAYS old. --transfers DAYS Purge transfers completed more than DAYS day ago. --labels DAYS Purge label items added more than DAYS days ago. + --cards DAY Purge card creator patrons added more than DAYS days ago. USAGE exit $_[0]; @@ -125,6 +126,7 @@ my $pOldIssues; my $pOldReserves; my $pTransfers; my $labels; +my $cards; GetOptions( 'h|help' => \$help, @@ -155,7 +157,8 @@ GetOptions( 'old-issues:i' => \$pOldIssues, 'old-reserves:i' => \$pOldReserves, 'transfers:i' => \$pTransfers, - 'labels:i' => \$labels, + 'labels:i' => \$labels, + 'cards:i' => \$cards, ) || usage(1); # Use default values @@ -197,6 +200,7 @@ unless ( $sessions || $pOldReserves || $pTransfers || $labels + || $cards ) { print "You did not specify any cleanup work for the script to do.\n\n"; usage(1); @@ -497,6 +501,18 @@ if ($labels) { print "Done with purging label items older than $labels days from batches.\n" if $verbose; } +if ($cards) { + print "Purging card creator patrons older than $cards days from batches.\n" if $verbose; + $sth = $dbh->prepare( + q{ + DELETE FROM creator_batches + WHERE timestamp < date_sub(curdate(), interval ? day) AND creator='Patroncards' + } + ); + $sth->execute($cards) or die $dbh->errstr; + print "Done with purging card creator patrons older than $cards days from batches.\n" if $verbose; +} + exit(0); sub RemoveOldSessions { --