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

(-)a/misc/cronjobs/cleanup_database.pl (-2 / +33 lines)
Lines 44-50 use Koha::UploadedFiles; Link Here
44
44
45
sub usage {
45
sub usage {
46
    print STDERR <<USAGE;
46
    print STDERR <<USAGE;
47
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]
47
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]
48
48
49
   -h --help          prints this help message, and exits, ignoring all
49
   -h --help          prints this help message, and exits, ignoring all
50
                      other options
50
                      other options
Lines 85-90 Usage: $0 [-h|--help] [--sessions] [--sessdays DAYS] [-v|--verbose] [--zebraqueu Link Here
85
   --temp-uploads-days DAYS Override the corresponding preference value.
85
   --temp-uploads-days DAYS Override the corresponding preference value.
86
   --uploads-missing FLAG Delete upload records for missing files when FLAG is true, count them otherwise
86
   --uploads-missing FLAG Delete upload records for missing files when FLAG is true, count them otherwise
87
   --statistics DAYS       Purge entries from statistics older than DAYS days.
87
   --statistics DAYS       Purge entries from statistics older than DAYS days.
88
   --deleted-catalog  DAYS Purge deleted catalog older than DAYS
89
                           in tables deleteditems, deletedbiblioitems, deletedbiblio_metadata and deletedbiblio
88
USAGE
90
USAGE
89
    exit $_[0];
91
    exit $_[0];
90
}
92
}
Lines 111-116 my $temp_uploads; Link Here
111
my $temp_uploads_days;
113
my $temp_uploads_days;
112
my $uploads_missing;
114
my $uploads_missing;
113
my $pStatistics;
115
my $pStatistics;
116
my $pDeletedCatalog;
114
117
115
GetOptions(
118
GetOptions(
116
    'h|help'            => \$help,
119
    'h|help'            => \$help,
Lines 135-140 GetOptions( Link Here
135
    'temp-uploads-days:i' => \$temp_uploads_days,
138
    'temp-uploads-days:i' => \$temp_uploads_days,
136
    'uploads-missing:i' => \$uploads_missing,
139
    'uploads-missing:i' => \$uploads_missing,
137
    'statistics:i'      => \$pStatistics,
140
    'statistics:i'      => \$pStatistics,
141
    'deleted-catalog:i' => \$pDeletedCatalog,
138
) || usage(1);
142
) || usage(1);
139
143
140
# Use default values
144
# Use default values
Lines 169-174 unless ( $sessions Link Here
169
    || $temp_uploads
173
    || $temp_uploads
170
    || defined $uploads_missing
174
    || defined $uploads_missing
171
    || $pStatistics
175
    || $pStatistics
176
    || $pDeletedCatalog
172
) {
177
) {
173
    print "You did not specify any cleanup work for the script to do.\n\n";
178
    print "You did not specify any cleanup work for the script to do.\n\n";
174
    usage(1);
179
    usage(1);
Lines 352-357 if ($pStatistics) { Link Here
352
    print "Done with purging statistics.\n" if $verbose;
357
    print "Done with purging statistics.\n" if $verbose;
353
}
358
}
354
359
360
if ($pDeletedCatalog) {
361
    print "Purging deleted catalog older than $pDeletedCatalog days.\n" if $verbose;
362
    my $sth1 = $dbh->prepare(
363
        q{
364
            DELETE FROM deleteditems
365
            WHERE timestamp < DATE_SUB(CURDATE(), INTERVAL ? DAY)
366
        }
367
    );
368
    my $sth2 = $dbh->prepare(
369
        q{
370
            DELETE FROM deletedbiblioitems
371
            WHERE timestamp < DATE_SUB(CURDATE(), INTERVAL ? DAY)
372
        }
373
    );
374
    my $sth3 = $dbh->prepare(
375
        q{
376
            DELETE FROM deletedbiblio
377
            WHERE timestamp < DATE_SUB(CURDATE(), INTERVAL ? DAY)
378
        }
379
    );
380
    # deletedbiblio_metadata is managed by FK with deletedbiblio
381
    $sth1->execute($pDeletedCatalog);
382
    $sth2->execute($pDeletedCatalog);
383
    $sth3->execute($pDeletedCatalog);
384
    print "Done with purging deleted catalog.\n" if $verbose;
385
}
386
355
exit(0);
387
exit(0);
356
388
357
sub RemoveOldSessions {
389
sub RemoveOldSessions {
358
- 

Return to bug 19008