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

(-)a/misc/cronjobs/cleanup_database.pl (-2 / +17 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 ]
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]
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 83-88 Usage: $0 [-h|--help] [--sessions] [--sessdays DAYS] [-v|--verbose] [--zebraqueu Link Here
83
   --temp-uploads-days DAYS Override the corresponding preference value.
83
   --temp-uploads-days DAYS Override the corresponding preference value.
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
USAGE
87
USAGE
87
    exit $_[0];
88
    exit $_[0];
88
}
89
}
Lines 109-114 my $temp_uploads; Link Here
109
my $temp_uploads_days;
110
my $temp_uploads_days;
110
my $uploads_missing;
111
my $uploads_missing;
111
my $oauth_tokens;
112
my $oauth_tokens;
113
my $pStatistics;
112
114
113
GetOptions(
115
GetOptions(
114
    'h|help'            => \$help,
116
    'h|help'            => \$help,
Lines 133-138 GetOptions( Link Here
133
    'temp-uploads-days:i' => \$temp_uploads_days,
135
    'temp-uploads-days:i' => \$temp_uploads_days,
134
    'uploads-missing:i' => \$uploads_missing,
136
    'uploads-missing:i' => \$uploads_missing,
135
    'oauth-tokens'      => \$oauth_tokens,
137
    'oauth-tokens'      => \$oauth_tokens,
138
    'statistics:i'      => \$pStatistics,
136
) || usage(1);
139
) || usage(1);
137
140
138
# Use default values
141
# Use default values
Lines 167-172 unless ( $sessions Link Here
167
    || $temp_uploads
170
    || $temp_uploads
168
    || defined $uploads_missing
171
    || defined $uploads_missing
169
    || $oauth_tokens
172
    || $oauth_tokens
173
    || $pStatistics
170
) {
174
) {
171
    print "You did not specify any cleanup work for the script to do.\n\n";
175
    print "You did not specify any cleanup work for the script to do.\n\n";
172
    usage(1);
176
    usage(1);
Lines 353-358 if ($oauth_tokens) { Link Here
353
    say "Removed $count expired OAuth2 tokens" if $verbose;
357
    say "Removed $count expired OAuth2 tokens" if $verbose;
354
}
358
}
355
359
360
if ($pStatistics) {
361
    print "Purging statistics older than $pStatistics days.\n" if $verbose;
362
    $sth = $dbh->prepare(
363
        q{
364
            DELETE FROM statistics
365
            WHERE datetime < DATE_SUB(CURDATE(), INTERVAL ? DAY)
366
        }
367
    );
368
    $sth->execute($pStatistics);
369
    print "Done with purging statistics.\n" if $verbose;
370
}
371
356
exit(0);
372
exit(0);
357
373
358
sub RemoveOldSessions {
374
sub RemoveOldSessions {
359
- 

Return to bug 19008