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

(-)a/misc/cronjobs/cleanup_database.pl (-2 / +27 lines)
Lines 20-25 Link Here
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use constant DEFAULT_ZEBRAQ_PURGEDAYS             => 30;
22
use constant DEFAULT_ZEBRAQ_PURGEDAYS             => 30;
23
use constant DEFAULT_ELASTICQ_PURGEDAYS           => 30;
23
use constant DEFAULT_MAIL_PURGEDAYS               => 30;
24
use constant DEFAULT_MAIL_PURGEDAYS               => 30;
24
use constant DEFAULT_IMPORT_PURGEDAYS             => 60;
25
use constant DEFAULT_IMPORT_PURGEDAYS             => 60;
25
use constant DEFAULT_LOGS_PURGEDAYS               => 180;
26
use constant DEFAULT_LOGS_PURGEDAYS               => 180;
Lines 49-55 use Koha::Patron::Debarments qw( DelDebarment ); Link Here
49
50
50
sub usage {
51
sub usage {
51
    print STDERR <<USAGE;
52
    print STDERR <<USAGE;
52
Usage: $0 [-h|--help] [--confirm] [--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] [--transfers DAYS] [--labels DAYS] [--cards DAYS]
53
Usage: $0 [-h|--help] [--confirm] [--sessions] [--sessdays DAYS] [-v|--verbose] [--zebraqueue DAYS] [--elasticqueue 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] [--transfers DAYS] [--labels DAYS] [--cards DAYS]
53
54
54
   -h --help          prints this help message, and exits, ignoring all
55
   -h --help          prints this help message, and exits, ignoring all
55
                      other options
56
                      other options
Lines 61-66 Usage: $0 [-h|--help] [--confirm] [--sessions] [--sessdays DAYS] [-v|--verbose] Link Here
61
                      about the run.
62
                      about the run.
62
   --zebraqueue DAYS  purge completed zebraqueue entries older than DAYS days.
63
   --zebraqueue DAYS  purge completed zebraqueue entries older than DAYS days.
63
                      Defaults to 30 days if no days specified.
64
                      Defaults to 30 days if no days specified.
65
   --elasticqueue DAYS  purge completed elastic reindex background job queue entries older than DAYS days.
66
                      Defaults to 30 days if no days specified.
64
   -m --mail DAYS     purge items from the mail queue that are older than DAYS days.
67
   -m --mail DAYS     purge items from the mail queue that are older than DAYS days.
65
                      Defaults to 30 days if no days specified.
68
                      Defaults to 30 days if no days specified.
66
   --merged           purged completed entries from need_merge_authorities.
69
   --merged           purged completed entries from need_merge_authorities.
Lines 117-122 my $sessions; Link Here
117
my $sess_days;
120
my $sess_days;
118
my $verbose;
121
my $verbose;
119
my $zebraqueue_days;
122
my $zebraqueue_days;
123
my $elasticqueue_days;
120
my $mail;
124
my $mail;
121
my $purge_merged;
125
my $purge_merged;
122
my $pImport;
126
my $pImport;
Lines 159-164 GetOptions( Link Here
159
    'v|verbose'         => \$verbose,
163
    'v|verbose'         => \$verbose,
160
    'm|mail:i'          => \$mail,
164
    'm|mail:i'          => \$mail,
161
    'zebraqueue:i'      => \$zebraqueue_days,
165
    'zebraqueue:i'      => \$zebraqueue_days,
166
    'elasticqueue:i'    => \$elasticqueue_days,
162
    'merged'            => \$purge_merged,
167
    'merged'            => \$purge_merged,
163
    'import:i'          => \$pImport,
168
    'import:i'          => \$pImport,
164
    'z3950'             => \$pZ3950,
169
    'z3950'             => \$pZ3950,
Lines 209-214 if ($help) { Link Here
209
214
210
unless ( $sessions
215
unless ( $sessions
211
    || $zebraqueue_days
216
    || $zebraqueue_days
217
    || $elasticqueue_days
212
    || $mail
218
    || $mail
213
    || $purge_merged
219
    || $purge_merged
214
    || $pImport
220
    || $pImport
Lines 303-308 if ($zebraqueue_days) { Link Here
303
    }
309
    }
304
}
310
}
305
311
312
if ($elasticqueue_days) {
313
    my $count = 0;
314
    print "Elastic queue (background jobs) purge triggered for $elasticqueue_days days.\n" if $verbose;
315
    $sth = $dbh->prepare(
316
        q{
317
            DELETE FROM background_jobs
318
            WHERE status='finished' AND ended_on < date_sub(curdate(), INTERVAL ? DAY) AND
319
            type = "update_elastic_index"
320
        }
321
    );
322
    if ( $confirm ) {
323
        $sth->execute($elasticqueue_days) or die $dbh->errstr;
324
        $count = $sth->rows;
325
    }
326
    if ( $verbose ) {
327
        say $confirm ? "$count elastic index jobs were deleted from the background jobs queue." : "Elastic reindex jobs from backgorund jobs queue would have been deleted";
328
        say "Done with elasticqueue purge.";
329
    }
330
}
331
306
if ($mail) {
332
if ($mail) {
307
    my $count = 0;
333
    my $count = 0;
308
    print "Mail queue purge triggered for $mail days.\n" if $verbose;
334
    print "Mail queue purge triggered for $mail days.\n" if $verbose;
309
- 

Return to bug 31629