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 224-232
if ($pDebarments && $allDebarments) {
Link Here
|
224 |
usage(1); |
229 |
usage(1); |
225 |
} |
230 |
} |
226 |
|
231 |
|
|
|
232 |
<<<<<<< HEAD |
227 |
say "Confirm flag not passed, running in dry-run mode..." unless $confirm; |
233 |
say "Confirm flag not passed, running in dry-run mode..." unless $confirm; |
228 |
|
234 |
|
229 |
cronlogaction() unless $confirm; |
235 |
cronlogaction() unless $confirm; |
|
|
236 |
======= |
237 |
if (!$mail && $letter_codes) { |
238 |
print "You should not specify --keep-lc if you're not cleaning emails.\n\n"; |
239 |
usage(1); |
240 |
} |
241 |
|
242 |
cronlogaction(); |
243 |
>>>>>>> Bug 21214: cleanup_database.pl --keep-lc to dodge deletion in message_queue based on letter_code |
230 |
|
244 |
|
231 |
my $dbh = C4::Context->dbh(); |
245 |
my $dbh = C4::Context->dbh(); |
232 |
my $sth; |
246 |
my $sth; |
Lines 283-288
if ($zebraqueue_days) {
Link Here
|
283 |
if ($mail) { |
297 |
if ($mail) { |
284 |
my $count = 0; |
298 |
my $count = 0; |
285 |
print "Mail queue purge triggered for $mail days.\n" if $verbose; |
299 |
print "Mail queue purge triggered for $mail days.\n" if $verbose; |
|
|
300 |
<<<<<<< HEAD |
286 |
$sth = $dbh->prepare( |
301 |
$sth = $dbh->prepare( |
287 |
q{ |
302 |
q{ |
288 |
DELETE FROM message_queue |
303 |
DELETE FROM message_queue |
Lines 297-302
if ($mail) {
Link Here
|
297 |
say $confirm ? "$count messages were deleted from the mail queue." : "Message from message_queue would have been deleted"; |
312 |
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."; |
313 |
say "Done with message_queue purge."; |
299 |
} |
314 |
} |
|
|
315 |
======= |
316 |
print "Not deleting emails of type $letter_codes.\n" if ($verbose && $letter_codes); |
317 |
my $query = q{ |
318 |
DELETE FROM message_queue |
319 |
WHERE time_queued < date_sub(curdate(), INTERVAL ? DAY) |
320 |
AND letter_code NOT IN ( ? ) |
321 |
}; |
322 |
my $quoted_codes = ''; |
323 |
if ($letter_codes) { |
324 |
my @codes = map { "'$_'" } split(',', $letter_codes); |
325 |
my $quoted_codes = join(',', @codes); |
326 |
} |
327 |
$sth = $dbh->prepare($query); |
328 |
$sth->execute($mail, $quoted_codes) or die $dbh->errstr; |
329 |
$count = $sth->rows; |
330 |
$sth->finish; |
331 |
print "$count messages were deleted from the mail queue.\nDone with message_queue purge.\n" if $verbose; |
332 |
>>>>>>> Bug 21214: cleanup_database.pl --keep-lc to dodge deletion in message_queue based on letter_code |
300 |
} |
333 |
} |
301 |
|
334 |
|
302 |
if ($purge_merged) { |
335 |
if ($purge_merged) { |
303 |
- |
|
|