Lines 71-76
Usage: $0 [-h|--help] [--confirm] [--sessions] [--sessdays DAYS] [-v|--verbose]
Link Here
|
71 |
Defaults to 30 days if no days specified. |
71 |
Defaults to 30 days if no days specified. |
72 |
-m --mail DAYS purge items from the mail queue that are older than DAYS days. |
72 |
-m --mail DAYS purge items from the mail queue that are older than DAYS days. |
73 |
Defaults to 30 days if no days specified. |
73 |
Defaults to 30 days if no days specified. |
|
|
74 |
--keep-lc LC[,LC]* only used in conjunction with -m/--mail. |
75 |
Keeps certain emails in the message_queue based on a |
76 |
comma-separated list of LETTER_CODES |
74 |
--merged purged completed entries from need_merge_authorities. |
77 |
--merged purged completed entries from need_merge_authorities. |
75 |
--messages DAYS purge entries from messages table older than DAYS days. |
78 |
--messages DAYS purge entries from messages table older than DAYS days. |
76 |
Defaults to 365 days if no days specified. |
79 |
Defaults to 365 days if no days specified. |
Lines 133-138
my $sess_days;
Link Here
|
133 |
my $verbose; |
136 |
my $verbose; |
134 |
my $zebraqueue_days; |
137 |
my $zebraqueue_days; |
135 |
my $mail; |
138 |
my $mail; |
|
|
139 |
my $letter_codes; |
136 |
my $purge_merged; |
140 |
my $purge_merged; |
137 |
my $pImport; |
141 |
my $pImport; |
138 |
my $pLogs; |
142 |
my $pLogs; |
Lines 178-183
GetOptions(
Link Here
|
178 |
'sessdays:i' => \$sess_days, |
182 |
'sessdays:i' => \$sess_days, |
179 |
'v|verbose' => \$verbose, |
183 |
'v|verbose' => \$verbose, |
180 |
'm|mail:i' => \$mail, |
184 |
'm|mail:i' => \$mail, |
|
|
185 |
'keep-lc:s' => \$letter_codes, |
181 |
'zebraqueue:i' => \$zebraqueue_days, |
186 |
'zebraqueue:i' => \$zebraqueue_days, |
182 |
'merged' => \$purge_merged, |
187 |
'merged' => \$purge_merged, |
183 |
'import:i' => \$pImport, |
188 |
'import:i' => \$pImport, |
Lines 284-289
say "Confirm flag not passed, running in dry-run mode..." unless $confirm;
Link Here
|
284 |
|
289 |
|
285 |
cronlogaction({ info => $command_line_options }); |
290 |
cronlogaction({ info => $command_line_options }); |
286 |
|
291 |
|
|
|
292 |
if (!$mail && $letter_codes) { |
293 |
print "You should not specify --keep-lc if you're not cleaning emails.\n\n"; |
294 |
usage(1); |
295 |
} |
296 |
|
287 |
my $dbh = C4::Context->dbh(); |
297 |
my $dbh = C4::Context->dbh(); |
288 |
my $sth; |
298 |
my $sth; |
289 |
my $sth2; |
299 |
my $sth2; |
Lines 337-356
if ($zebraqueue_days) {
Link Here
|
337 |
if ($mail) { |
347 |
if ($mail) { |
338 |
my $count = 0; |
348 |
my $count = 0; |
339 |
print "Mail queue purge triggered for $mail days.\n" if $verbose; |
349 |
print "Mail queue purge triggered for $mail days.\n" if $verbose; |
340 |
$sth = $dbh->prepare( |
350 |
print "Not deleting emails of type $letter_codes.\n" if ($verbose && $letter_codes); |
341 |
q{ |
351 |
my $query = q{ |
342 |
DELETE FROM message_queue |
352 |
DELETE FROM message_queue |
343 |
WHERE time_queued < date_sub(curdate(), INTERVAL ? DAY) |
353 |
WHERE time_queued < date_sub(curdate(), INTERVAL ? DAY) |
344 |
} |
354 |
AND letter_code NOT IN ( ? ) |
345 |
); |
355 |
}; |
346 |
if ( $confirm ) { |
356 |
my $quoted_codes = ''; |
347 |
$sth->execute($mail) or die $dbh->errstr; |
357 |
if ($letter_codes) { |
348 |
$count = $sth->rows; |
358 |
my @codes = map { "'$_'" } split(',', $letter_codes); |
349 |
} |
359 |
my $quoted_codes = join(',', @codes); |
350 |
if ( $verbose ) { |
360 |
} |
351 |
say $confirm ? "$count messages were deleted from the mail queue." : "Message from message_queue would have been deleted"; |
361 |
$sth = $dbh->prepare($query); |
352 |
say "Done with message_queue purge."; |
362 |
$sth->execute($mail, $quoted_codes) or die $dbh->errstr; |
353 |
} |
363 |
$count = $sth->rows; |
|
|
364 |
$sth->finish; |
365 |
print "$count messages were deleted from the mail queue.\nDone with message_queue purge.\n" if $verbose; |
354 |
} |
366 |
} |
355 |
|
367 |
|
356 |
if ($purge_merged) { |
368 |
if ($purge_merged) { |
357 |
- |
|
|