@@ -, +, @@ - Count : - Run cleanup : misc/cronjobs/cleanup_database.pl -v --deleted-catalog 30 - Recount --- misc/cronjobs/cleanup_database.pl | 34 ++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) --- a/misc/cronjobs/cleanup_database.pl +++ a/misc/cronjobs/cleanup_database.pl @@ -45,7 +45,7 @@ use Koha::UploadedFiles; sub usage { print STDERR < \$help, @@ -136,6 +139,7 @@ GetOptions( 'uploads-missing:i' => \$uploads_missing, 'oauth-tokens' => \$oauth_tokens, 'statistics:i' => \$pStatistics, + 'deleted-catalog:i' => \$pDeletedCatalog, ) || usage(1); # Use default values @@ -171,6 +175,7 @@ unless ( $sessions || defined $uploads_missing || $oauth_tokens || $pStatistics + || $pDeletedCatalog ) { print "You did not specify any cleanup work for the script to do.\n\n"; usage(1); @@ -369,6 +374,33 @@ if ($pStatistics) { print "Done with purging statistics.\n" if $verbose; } +if ($pDeletedCatalog) { + print "Purging deleted catalog older than $pDeletedCatalog days.\n" if $verbose; + my $sth1 = $dbh->prepare( + q{ + DELETE FROM deleteditems + WHERE timestamp < DATE_SUB(CURDATE(), INTERVAL ? DAY) + } + ); + my $sth2 = $dbh->prepare( + q{ + DELETE FROM deletedbiblioitems + WHERE timestamp < DATE_SUB(CURDATE(), INTERVAL ? DAY) + } + ); + my $sth3 = $dbh->prepare( + q{ + DELETE FROM deletedbiblio + WHERE timestamp < DATE_SUB(CURDATE(), INTERVAL ? DAY) + } + ); + # deletedbiblio_metadata is managed by FK with deletedbiblio + $sth1->execute($pDeletedCatalog); + $sth2->execute($pDeletedCatalog); + $sth3->execute($pDeletedCatalog); + print "Done with purging deleted catalog.\n" if $verbose; +} + exit(0); sub RemoveOldSessions { --