Bug 19008: More database cleanups - old reserves
misc/cronjobs/cleanup_database.pl provides some database cleanup. Yet some tables that could need cleanup are not in this script. This patch adds cleanup for old_reserves table. Test plan : - Count : select count(*),date(timestamp) from old_reserves group by date(timestamp); - Run cleanup : misc/cronjobs/cleanup_database.pl -v --old-reserves 30 - Recount Signed-off-by: Mark Tompsett <mtompset@hotmail.com> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Joy Nelson <joy@bywatersolutions.com>
This commit is contained in:
parent
ce96ed4336
commit
9ce0f3a73e
|
|
@ -45,7 +45,7 @@ use Koha::UploadedFiles;
|
|||
|
||||
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] [--deleted-catalog DAYS] [--deleted-patrons DAYS] [--old-issues 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] [--deleted-patrons DAYS] [--old-issues DAYS] [--old-reserves DAYS]
|
||||
|
||||
-h --help prints this help message, and exits, ignoring all
|
||||
other options
|
||||
|
|
@ -88,6 +88,7 @@ Usage: $0 [-h|--help] [--sessions] [--sessdays DAYS] [-v|--verbose] [--zebraqueu
|
|||
in tables deleteditems, deletedbiblioitems, deletedbiblio_metadata and deletedbiblio
|
||||
--deleted-patrons DAYS Purge deleted patrons older than DAYS days.
|
||||
--old-issues DAYS Purge old issues older than DAYS days.
|
||||
--old-reserves DAYS Purge old reserves older than DAYS days.
|
||||
USAGE
|
||||
exit $_[0];
|
||||
}
|
||||
|
|
@ -118,6 +119,7 @@ my $pStatistics;
|
|||
my $pDeletedCatalog;
|
||||
my $pDeletedPatrons;
|
||||
my $pOldIssues;
|
||||
my $pOldReserves;
|
||||
|
||||
GetOptions(
|
||||
'h|help' => \$help,
|
||||
|
|
@ -146,6 +148,7 @@ GetOptions(
|
|||
'deleted-catalog:i' => \$pDeletedCatalog,
|
||||
'deleted-patrons:i' => \$pDeletedPatrons,
|
||||
'old-issues:i' => \$pOldIssues,
|
||||
'old-reserves:i' => \$pOldReserves,
|
||||
) || usage(1);
|
||||
|
||||
# Use default values
|
||||
|
|
@ -184,6 +187,7 @@ unless ( $sessions
|
|||
|| $pDeletedCatalog
|
||||
|| $pDeletedPatrons
|
||||
|| $pOldIssues
|
||||
|| $pOldReserves
|
||||
) {
|
||||
print "You did not specify any cleanup work for the script to do.\n\n";
|
||||
usage(1);
|
||||
|
|
@ -448,6 +452,18 @@ if ($pOldIssues) {
|
|||
print "Done with purging old issues.\n" if $verbose;
|
||||
}
|
||||
|
||||
if ($pOldReserves) {
|
||||
print "Purging old reserves older than $pOldReserves days.\n" if $verbose;
|
||||
$sth = $dbh->prepare(
|
||||
q{
|
||||
DELETE FROM old_reserves
|
||||
WHERE timestamp < DATE_SUB(CURDATE(), INTERVAL ? DAY)
|
||||
}
|
||||
);
|
||||
$sth->execute($pOldReserves);
|
||||
print "Done with purging old reserves.\n" if $verbose;
|
||||
}
|
||||
|
||||
exit(0);
|
||||
|
||||
sub RemoveOldSessions {
|
||||
|
|
|
|||
Loading…
Reference in New Issue