Lines 57-62
Usage: $0 [-h|--help] [--sessions] [--sessdays DAYS] [-v|--verbose] [--zebraqueu
Link Here
|
57 |
Defaults to 30 days if no days specified. |
57 |
Defaults to 30 days if no days specified. |
58 |
-m --mail DAYS purge items from the mail queue that are older than DAYS days. |
58 |
-m --mail DAYS purge items from the mail queue that are older than DAYS days. |
59 |
Defaults to 30 days if no days specified. |
59 |
Defaults to 30 days if no days specified. |
|
|
60 |
--keep-lc LC[,LC]* only used in conjunction with -m/--mail. |
61 |
Keeps certain emails in the message_queue based on a |
62 |
comma-separated list of LETTER_CODES |
60 |
--merged purged completed entries from need_merge_authorities. |
63 |
--merged purged completed entries from need_merge_authorities. |
61 |
--import DAYS purge records from import tables older than DAYS days. |
64 |
--import DAYS purge records from import tables older than DAYS days. |
62 |
Defaults to 60 days if no days specified. |
65 |
Defaults to 60 days if no days specified. |
Lines 92-97
my $sess_days;
Link Here
|
92 |
my $verbose; |
95 |
my $verbose; |
93 |
my $zebraqueue_days; |
96 |
my $zebraqueue_days; |
94 |
my $mail; |
97 |
my $mail; |
|
|
98 |
my $letter_codes; |
95 |
my $purge_merged; |
99 |
my $purge_merged; |
96 |
my $pImport; |
100 |
my $pImport; |
97 |
my $pLogs; |
101 |
my $pLogs; |
Lines 115-120
GetOptions(
Link Here
|
115 |
'sessdays:i' => \$sess_days, |
119 |
'sessdays:i' => \$sess_days, |
116 |
'v|verbose' => \$verbose, |
120 |
'v|verbose' => \$verbose, |
117 |
'm|mail:i' => \$mail, |
121 |
'm|mail:i' => \$mail, |
|
|
122 |
'keep-lc:s' => \$letter_codes, |
118 |
'zebraqueue:i' => \$zebraqueue_days, |
123 |
'zebraqueue:i' => \$zebraqueue_days, |
119 |
'merged' => \$purge_merged, |
124 |
'merged' => \$purge_merged, |
120 |
'import:i' => \$pImport, |
125 |
'import:i' => \$pImport, |
Lines 176-181
if ($pDebarments && $allDebarments) {
Link Here
|
176 |
usage(1); |
181 |
usage(1); |
177 |
} |
182 |
} |
178 |
|
183 |
|
|
|
184 |
if (!$mail && $letter_codes) { |
185 |
print "You should not specify --keep-lc if you're not cleaning emails.\n\n"; |
186 |
usage(1); |
187 |
} |
188 |
|
179 |
cronlogaction(); |
189 |
cronlogaction(); |
180 |
|
190 |
|
181 |
my $dbh = C4::Context->dbh(); |
191 |
my $dbh = C4::Context->dbh(); |
Lines 224-236
if ($zebraqueue_days) {
Link Here
|
224 |
|
234 |
|
225 |
if ($mail) { |
235 |
if ($mail) { |
226 |
print "Mail queue purge triggered for $mail days.\n" if $verbose; |
236 |
print "Mail queue purge triggered for $mail days.\n" if $verbose; |
227 |
$sth = $dbh->prepare( |
237 |
print "Not deleting emails of type $letter_codes.\n" if ($verbose && $letter_codes); |
228 |
q{ |
238 |
my $query = q{ |
229 |
DELETE FROM message_queue |
239 |
DELETE FROM message_queue |
230 |
WHERE time_queued < date_sub(curdate(), INTERVAL ? DAY) |
240 |
WHERE time_queued < date_sub(curdate(), INTERVAL ? DAY) |
231 |
} |
241 |
AND letter_code NOT IN ( ? ) |
232 |
); |
242 |
}; |
233 |
$sth->execute($mail) or die $dbh->errstr; |
243 |
my $quoted_codes = ''; |
|
|
244 |
if ($letter_codes) { |
245 |
my @codes = map { "'$_'" } split(',', $letter_codes); |
246 |
my $quoted_codes = join(',', @codes); |
247 |
} |
248 |
$sth = $dbh->prepare($query); |
249 |
$sth->execute($mail, $quoted_codes) or die $dbh->errstr; |
234 |
$count = $sth->rows; |
250 |
$count = $sth->rows; |
235 |
$sth->finish; |
251 |
$sth->finish; |
236 |
print "$count messages were deleted from the mail queue.\nDone with message_queue purge.\n" if $verbose; |
252 |
print "$count messages were deleted from the mail queue.\nDone with message_queue purge.\n" if $verbose; |
237 |
- |
|
|