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] [--fees DAYS] [--temp-uploads] [--temp-uploads-days DAYS] [--uploads-missing 0|1 ] [--statistics 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] [--fees DAYS] [--temp-uploads] [--temp-uploads-days DAYS] [--uploads-missing 0|1 ] [--statistics DAYS] [--deleted-catalog DAYS]
-h --help prints this help message, and exits, ignoring all
other options
--uploads-missing FLAG Delete upload records for missing files when FLAG is true, count them otherwise
--oauth-tokens Delete expired OAuth2 tokens
--statistics DAYS Purge entries from statistics older than DAYS days.
+ --deleted-catalog DAYS Purge deleted catalog older than DAYS
+ in tables deleteditems, deletedbiblioitems, deletedbiblio_metadata and deletedbiblio
USAGE
exit $_[0];
}
my $uploads_missing;
my $oauth_tokens;
my $pStatistics;
+my $pDeletedCatalog;
GetOptions(
'h|help' => \$help,
'uploads-missing:i' => \$uploads_missing,
'oauth-tokens' => \$oauth_tokens,
'statistics:i' => \$pStatistics,
+ 'deleted-catalog:i' => \$pDeletedCatalog,
) || usage(1);
# Use default values
|| defined $uploads_missing
|| $oauth_tokens
|| $pStatistics
+ || $pDeletedCatalog
) {
print "You did not specify any cleanup work for the script to do.\n\n";
usage(1);
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 {