View | Details | Raw Unified | Return to bug 19008
Collapse All | Expand All

(-)a/misc/cronjobs/cleanup_database.pl (-2 / +33 lines)
Lines 45-51 use Koha::UploadedFiles; Link Here
45
45
46
sub usage {
46
sub usage {
47
    print STDERR <<USAGE;
47
    print STDERR <<USAGE;
48
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]
48
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]
49
49
50
   -h --help          prints this help message, and exits, ignoring all
50
   -h --help          prints this help message, and exits, ignoring all
51
                      other options
51
                      other options
Lines 84-89 Usage: $0 [-h|--help] [--sessions] [--sessdays DAYS] [-v|--verbose] [--zebraqueu Link Here
84
   --uploads-missing FLAG Delete upload records for missing files when FLAG is true, count them otherwise
84
   --uploads-missing FLAG Delete upload records for missing files when FLAG is true, count them otherwise
85
   --oauth-tokens     Delete expired OAuth2 tokens
85
   --oauth-tokens     Delete expired OAuth2 tokens
86
   --statistics DAYS       Purge entries from statistics older than DAYS days.
86
   --statistics DAYS       Purge entries from statistics older than DAYS days.
87
   --deleted-catalog  DAYS Purge deleted catalog older than DAYS
88
                           in tables deleteditems, deletedbiblioitems, deletedbiblio_metadata and deletedbiblio
87
USAGE
89
USAGE
88
    exit $_[0];
90
    exit $_[0];
89
}
91
}
Lines 111-116 my $temp_uploads_days; Link Here
111
my $uploads_missing;
113
my $uploads_missing;
112
my $oauth_tokens;
114
my $oauth_tokens;
113
my $pStatistics;
115
my $pStatistics;
116
my $pDeletedCatalog;
114
117
115
GetOptions(
118
GetOptions(
116
    'h|help'            => \$help,
119
    'h|help'            => \$help,
Lines 136-141 GetOptions( Link Here
136
    'uploads-missing:i' => \$uploads_missing,
139
    'uploads-missing:i' => \$uploads_missing,
137
    'oauth-tokens'      => \$oauth_tokens,
140
    'oauth-tokens'      => \$oauth_tokens,
138
    'statistics:i'      => \$pStatistics,
141
    'statistics:i'      => \$pStatistics,
142
    'deleted-catalog:i' => \$pDeletedCatalog,
139
) || usage(1);
143
) || usage(1);
140
144
141
# Use default values
145
# Use default values
Lines 171-176 unless ( $sessions Link Here
171
    || defined $uploads_missing
175
    || defined $uploads_missing
172
    || $oauth_tokens
176
    || $oauth_tokens
173
    || $pStatistics
177
    || $pStatistics
178
    || $pDeletedCatalog
174
) {
179
) {
175
    print "You did not specify any cleanup work for the script to do.\n\n";
180
    print "You did not specify any cleanup work for the script to do.\n\n";
176
    usage(1);
181
    usage(1);
Lines 369-374 if ($pStatistics) { Link Here
369
    print "Done with purging statistics.\n" if $verbose;
374
    print "Done with purging statistics.\n" if $verbose;
370
}
375
}
371
376
377
if ($pDeletedCatalog) {
378
    print "Purging deleted catalog older than $pDeletedCatalog days.\n" if $verbose;
379
    my $sth1 = $dbh->prepare(
380
        q{
381
            DELETE FROM deleteditems
382
            WHERE timestamp < DATE_SUB(CURDATE(), INTERVAL ? DAY)
383
        }
384
    );
385
    my $sth2 = $dbh->prepare(
386
        q{
387
            DELETE FROM deletedbiblioitems
388
            WHERE timestamp < DATE_SUB(CURDATE(), INTERVAL ? DAY)
389
        }
390
    );
391
    my $sth3 = $dbh->prepare(
392
        q{
393
            DELETE FROM deletedbiblio
394
            WHERE timestamp < DATE_SUB(CURDATE(), INTERVAL ? DAY)
395
        }
396
    );
397
    # deletedbiblio_metadata is managed by FK with deletedbiblio
398
    $sth1->execute($pDeletedCatalog);
399
    $sth2->execute($pDeletedCatalog);
400
    $sth3->execute($pDeletedCatalog);
401
    print "Done with purging deleted catalog.\n" if $verbose;
402
}
403
372
exit(0);
404
exit(0);
373
405
374
sub RemoveOldSessions {
406
sub RemoveOldSessions {
375
- 

Return to bug 19008