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 132-137
my $sess_days;
Link Here
|
132 |
my $verbose; |
135 |
my $verbose; |
133 |
my $zebraqueue_days; |
136 |
my $zebraqueue_days; |
134 |
my $mail; |
137 |
my $mail; |
|
|
138 |
my $letter_codes; |
135 |
my $purge_merged; |
139 |
my $purge_merged; |
136 |
my $pImport; |
140 |
my $pImport; |
137 |
my $pLogs; |
141 |
my $pLogs; |
Lines 176-181
GetOptions(
Link Here
|
176 |
'sessdays:i' => \$sess_days, |
180 |
'sessdays:i' => \$sess_days, |
177 |
'v|verbose' => \$verbose, |
181 |
'v|verbose' => \$verbose, |
178 |
'm|mail:i' => \$mail, |
182 |
'm|mail:i' => \$mail, |
|
|
183 |
'keep-lc:s' => \$letter_codes, |
179 |
'zebraqueue:i' => \$zebraqueue_days, |
184 |
'zebraqueue:i' => \$zebraqueue_days, |
180 |
'merged' => \$purge_merged, |
185 |
'merged' => \$purge_merged, |
181 |
'import:i' => \$pImport, |
186 |
'import:i' => \$pImport, |
Lines 281-286
say "Confirm flag not passed, running in dry-run mode..." unless $confirm;
Link Here
|
281 |
|
286 |
|
282 |
cronlogaction({ info => $command_line_options }); |
287 |
cronlogaction({ info => $command_line_options }); |
283 |
|
288 |
|
|
|
289 |
if (!$mail && $letter_codes) { |
290 |
print "You should not specify --keep-lc if you're not cleaning emails.\n\n"; |
291 |
usage(1); |
292 |
} |
293 |
|
284 |
my $dbh = C4::Context->dbh(); |
294 |
my $dbh = C4::Context->dbh(); |
285 |
my $sth; |
295 |
my $sth; |
286 |
my $sth2; |
296 |
my $sth2; |
Lines 334-353
if ($zebraqueue_days) {
Link Here
|
334 |
if ($mail) { |
344 |
if ($mail) { |
335 |
my $count = 0; |
345 |
my $count = 0; |
336 |
print "Mail queue purge triggered for $mail days.\n" if $verbose; |
346 |
print "Mail queue purge triggered for $mail days.\n" if $verbose; |
337 |
$sth = $dbh->prepare( |
347 |
print "Not deleting emails of type $letter_codes.\n" if ($verbose && $letter_codes); |
338 |
q{ |
348 |
my $query = q{ |
339 |
DELETE FROM message_queue |
349 |
DELETE FROM message_queue |
340 |
WHERE time_queued < date_sub(curdate(), INTERVAL ? DAY) |
350 |
WHERE time_queued < date_sub(curdate(), INTERVAL ? DAY) |
341 |
} |
351 |
AND letter_code NOT IN ( ? ) |
342 |
); |
352 |
}; |
343 |
if ( $confirm ) { |
353 |
my $quoted_codes = ''; |
344 |
$sth->execute($mail) or die $dbh->errstr; |
354 |
if ($letter_codes) { |
345 |
$count = $sth->rows; |
355 |
my @codes = map { "'$_'" } split(',', $letter_codes); |
346 |
} |
356 |
my $quoted_codes = join(',', @codes); |
347 |
if ( $verbose ) { |
357 |
} |
348 |
say $confirm ? "$count messages were deleted from the mail queue." : "Message from message_queue would have been deleted"; |
358 |
$sth = $dbh->prepare($query); |
349 |
say "Done with message_queue purge."; |
359 |
$sth->execute($mail, $quoted_codes) or die $dbh->errstr; |
350 |
} |
360 |
$count = $sth->rows; |
|
|
361 |
$sth->finish; |
362 |
print "$count messages were deleted from the mail queue.\nDone with message_queue purge.\n" if $verbose; |
351 |
} |
363 |
} |
352 |
|
364 |
|
353 |
if ($purge_merged) { |
365 |
if ($purge_merged) { |
354 |
- |
|
|