Lines 67-72
Usage: $0 [-h|--help] [--confirm] [--sessions] [--sessdays DAYS] [-v|--verbose]
Link Here
|
67 |
Defaults to 30 days if no days specified. |
67 |
Defaults to 30 days if no days specified. |
68 |
-m --mail DAYS purge items from the mail queue that are older than DAYS days. |
68 |
-m --mail DAYS purge items from the mail queue that are older than DAYS days. |
69 |
Defaults to 30 days if no days specified. |
69 |
Defaults to 30 days if no days specified. |
|
|
70 |
--keep-lc LC[,LC]* only used in conjunction with -m/--mail. |
71 |
Keeps certain emails in the message_queue based on a |
72 |
comma-separated list of LETTER_CODES |
70 |
--merged purged completed entries from need_merge_authorities. |
73 |
--merged purged completed entries from need_merge_authorities. |
71 |
--import DAYS purge records from import tables older than DAYS days. |
74 |
--import DAYS purge records from import tables older than DAYS days. |
72 |
Defaults to 60 days if no days specified. |
75 |
Defaults to 60 days if no days specified. |
Lines 114-119
my $sess_days;
Link Here
|
114 |
my $verbose; |
117 |
my $verbose; |
115 |
my $zebraqueue_days; |
118 |
my $zebraqueue_days; |
116 |
my $mail; |
119 |
my $mail; |
|
|
120 |
my $letter_codes; |
117 |
my $purge_merged; |
121 |
my $purge_merged; |
118 |
my $pImport; |
122 |
my $pImport; |
119 |
my $pLogs; |
123 |
my $pLogs; |
Lines 145-150
GetOptions(
Link Here
|
145 |
'sessdays:i' => \$sess_days, |
149 |
'sessdays:i' => \$sess_days, |
146 |
'v|verbose' => \$verbose, |
150 |
'v|verbose' => \$verbose, |
147 |
'm|mail:i' => \$mail, |
151 |
'm|mail:i' => \$mail, |
|
|
152 |
'keep-lc:s' => \$letter_codes, |
148 |
'zebraqueue:i' => \$zebraqueue_days, |
153 |
'zebraqueue:i' => \$zebraqueue_days, |
149 |
'merged' => \$purge_merged, |
154 |
'merged' => \$purge_merged, |
150 |
'import:i' => \$pImport, |
155 |
'import:i' => \$pImport, |
Lines 228-233
say "Confirm flag not passed, running in dry-run mode..." unless $confirm;
Link Here
|
228 |
|
233 |
|
229 |
cronlogaction() unless $confirm; |
234 |
cronlogaction() unless $confirm; |
230 |
|
235 |
|
|
|
236 |
if (!$mail && $letter_codes) { |
237 |
print "You should not specify --keep-lc if you're not cleaning emails.\n\n"; |
238 |
usage(1); |
239 |
} |
240 |
|
231 |
my $dbh = C4::Context->dbh(); |
241 |
my $dbh = C4::Context->dbh(); |
232 |
my $sth; |
242 |
my $sth; |
233 |
my $sth2; |
243 |
my $sth2; |
Lines 283-302
if ($zebraqueue_days) {
Link Here
|
283 |
if ($mail) { |
293 |
if ($mail) { |
284 |
my $count = 0; |
294 |
my $count = 0; |
285 |
print "Mail queue purge triggered for $mail days.\n" if $verbose; |
295 |
print "Mail queue purge triggered for $mail days.\n" if $verbose; |
286 |
$sth = $dbh->prepare( |
296 |
print "Not deleting emails of type $letter_codes.\n" if ($verbose && $letter_codes); |
287 |
q{ |
297 |
my $query = q{ |
288 |
DELETE FROM message_queue |
298 |
DELETE FROM message_queue |
289 |
WHERE time_queued < date_sub(curdate(), INTERVAL ? DAY) |
299 |
WHERE time_queued < date_sub(curdate(), INTERVAL ? DAY) |
290 |
} |
300 |
AND letter_code NOT IN ( ? ) |
291 |
); |
301 |
}; |
292 |
if ( $confirm ) { |
302 |
my $quoted_codes = ''; |
293 |
$sth->execute($mail) or die $dbh->errstr; |
303 |
if ($letter_codes) { |
294 |
$count = $sth->rows; |
304 |
my @codes = map { "'$_'" } split(',', $letter_codes); |
295 |
} |
305 |
my $quoted_codes = join(',', @codes); |
296 |
if ( $verbose ) { |
|
|
297 |
say $confirm ? "$count messages were deleted from the mail queue." : "Message from message_queue would have been deleted"; |
298 |
say "Done with message_queue purge."; |
299 |
} |
306 |
} |
|
|
307 |
$sth = $dbh->prepare($query); |
308 |
$sth->execute($mail, $quoted_codes) or die $dbh->errstr; |
309 |
$count = $sth->rows; |
310 |
$sth->finish; |
311 |
print "$count messages were deleted from the mail queue.\nDone with message_queue purge.\n" if $verbose; |
300 |
} |
312 |
} |
301 |
|
313 |
|
302 |
if ($purge_merged) { |
314 |
if ($purge_merged) { |
303 |
- |
|
|