Lines 20-25
Link Here
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use constant DEFAULT_ZEBRAQ_PURGEDAYS => 30; |
22 |
use constant DEFAULT_ZEBRAQ_PURGEDAYS => 30; |
|
|
23 |
use constant DEFAULT_ZEBRAQ_UNDONE_PURGEDAYS => 90; |
23 |
use constant DEFAULT_MAIL_PURGEDAYS => 30; |
24 |
use constant DEFAULT_MAIL_PURGEDAYS => 30; |
24 |
use constant DEFAULT_IMPORT_PURGEDAYS => 60; |
25 |
use constant DEFAULT_IMPORT_PURGEDAYS => 60; |
25 |
use constant DEFAULT_LOGS_PURGEDAYS => 180; |
26 |
use constant DEFAULT_LOGS_PURGEDAYS => 180; |
Lines 57-63
use Koha::UploadedFiles;
Link Here
|
57 |
|
58 |
|
58 |
sub usage { |
59 |
sub usage { |
59 |
print STDERR <<USAGE; |
60 |
print STDERR <<USAGE; |
60 |
Usage: $0 [-h|--help] [--confirm] [--sessions] [--sessdays DAYS] [-v|--verbose] [--zebraqueue DAYS] [-m|--mail] [--merged] [--import DAYS] [--logs DAYS] [--searchhistory DAYS] [--restrictions DAYS] [--all-restrictions] [--fees DAYS] [--temp-uploads] [--temp-uploads-days DAYS] [--uploads-missing 0|1 ] [--statistics DAYS] [--deleted-catalog DAYS] [--deleted-patrons DAYS] [--old-issues DAYS] [--old-reserves DAYS] [--transfers DAYS] [--labels DAYS] [--cards DAYS] [--bg-days DAYS [--bg-type TYPE] ] [--edifact-messages DAYS] |
61 |
Usage: $0 [-h|--help] [--confirm] [--sessions] [--sessdays DAYS] [-v|--verbose] [--zebraqueue DAYS] [--zebraqueue-undone DAYS] [-m|--mail] [--merged] [--import DAYS] [--logs DAYS] [--searchhistory DAYS] [--restrictions DAYS] [--all-restrictions] [--fees DAYS] [--temp-uploads] [--temp-uploads-days DAYS] [--uploads-missing 0|1 ] [--statistics DAYS] [--deleted-catalog DAYS] [--deleted-patrons DAYS] [--old-issues DAYS] [--old-reserves DAYS] [--transfers DAYS] [--labels DAYS] [--cards DAYS] [--bg-days DAYS [--bg-type TYPE] ] [--edifact-messages DAYS] |
61 |
|
62 |
|
62 |
-h --help prints this help message, and exits, ignoring all |
63 |
-h --help prints this help message, and exits, ignoring all |
63 |
other options |
64 |
other options |
Lines 69-74
Usage: $0 [-h|--help] [--confirm] [--sessions] [--sessdays DAYS] [-v|--verbose]
Link Here
|
69 |
about the run. |
70 |
about the run. |
70 |
--zebraqueue DAYS purge completed zebraqueue entries older than DAYS days. |
71 |
--zebraqueue DAYS purge completed zebraqueue entries older than DAYS days. |
71 |
Defaults to 30 days if no days specified. |
72 |
Defaults to 30 days if no days specified. |
|
|
73 |
--zebraqueue-undone DAYS purge uncompleted zebraqueue entries older than DAYS days. |
74 |
Defaults to 90 days if no days specified. |
72 |
-m --mail DAYS purge items from the mail queue that are older than DAYS days. |
75 |
-m --mail DAYS purge items from the mail queue that are older than DAYS days. |
73 |
Defaults to 30 days if no days specified. |
76 |
Defaults to 30 days if no days specified. |
74 |
--merged purged completed entries from need_merge_authorities. |
77 |
--merged purged completed entries from need_merge_authorities. |
Lines 135-140
my $sessions;
Link Here
|
135 |
my $sess_days; |
138 |
my $sess_days; |
136 |
my $verbose; |
139 |
my $verbose; |
137 |
my $zebraqueue_days; |
140 |
my $zebraqueue_days; |
|
|
141 |
my $zebraqueue_days_undone; |
138 |
my $mail; |
142 |
my $mail; |
139 |
my $purge_merged; |
143 |
my $purge_merged; |
140 |
my $pImport; |
144 |
my $pImport; |
Lines 182-187
GetOptions(
Link Here
|
182 |
'v|verbose' => \$verbose, |
186 |
'v|verbose' => \$verbose, |
183 |
'm|mail:i' => \$mail, |
187 |
'm|mail:i' => \$mail, |
184 |
'zebraqueue:i' => \$zebraqueue_days, |
188 |
'zebraqueue:i' => \$zebraqueue_days, |
|
|
189 |
'zebraqueue-undone:i' => \$zebraqueue_days_undone, |
185 |
'merged' => \$purge_merged, |
190 |
'merged' => \$purge_merged, |
186 |
'import:i' => \$pImport, |
191 |
'import:i' => \$pImport, |
187 |
'z3950' => \$pZ3950, |
192 |
'z3950' => \$pZ3950, |
Lines 221-237
GetOptions(
Link Here
|
221 |
) || usage(1); |
226 |
) || usage(1); |
222 |
|
227 |
|
223 |
# Use default values |
228 |
# Use default values |
224 |
$sessions = 1 if $sess_days && $sess_days > 0; |
229 |
$sessions = 1 if $sess_days && $sess_days > 0; |
225 |
$pImport = DEFAULT_IMPORT_PURGEDAYS if defined($pImport) && $pImport == 0; |
230 |
$pImport = DEFAULT_IMPORT_PURGEDAYS if defined($pImport) && $pImport == 0; |
226 |
$pLogs = DEFAULT_LOGS_PURGEDAYS if defined($pLogs) && $pLogs == 0; |
231 |
$pLogs = DEFAULT_LOGS_PURGEDAYS if defined($pLogs) && $pLogs == 0; |
227 |
$zebraqueue_days = DEFAULT_ZEBRAQ_PURGEDAYS if defined($zebraqueue_days) && $zebraqueue_days == 0; |
232 |
$zebraqueue_days = DEFAULT_ZEBRAQ_PURGEDAYS if defined($zebraqueue_days) && $zebraqueue_days == 0; |
228 |
$mail = DEFAULT_MAIL_PURGEDAYS if defined($mail) && $mail == 0; |
233 |
$zebraqueue_days_undone = DEFAULT_ZEBRAQ_UNDONE_PURGEDAYS if defined($zebraqueue_days_undone) && $zebraqueue_days_undone == 0; |
229 |
$pSearchhistory = DEFAULT_SEARCHHISTORY_PURGEDAYS if defined($pSearchhistory) && $pSearchhistory == 0; |
234 |
$mail = DEFAULT_MAIL_PURGEDAYS if defined($mail) && $mail == 0; |
230 |
$pDebarments = DEFAULT_DEBARMENTS_PURGEDAYS if defined($pDebarments) && $pDebarments == 0; |
235 |
$pSearchhistory = DEFAULT_SEARCHHISTORY_PURGEDAYS if defined($pSearchhistory) && $pSearchhistory == 0; |
231 |
$pMessages = DEFAULT_MESSAGES_PURGEDAYS if defined($pMessages) && $pMessages == 0; |
236 |
$pDebarments = DEFAULT_DEBARMENTS_PURGEDAYS if defined($pDebarments) && $pDebarments == 0; |
232 |
$jobs_days = DEFAULT_JOBS_PURGEDAYS if defined($jobs_days) && $jobs_days == 0; |
237 |
$pMessages = DEFAULT_MESSAGES_PURGEDAYS if defined($pMessages) && $pMessages == 0; |
233 |
@jobs_types = (DEFAULT_JOBS_PURGETYPES) if $jobs_days && @jobs_types == 0; |
238 |
$jobs_days = DEFAULT_JOBS_PURGEDAYS if defined($jobs_days) && $jobs_days == 0; |
234 |
$edifact_msg_days = DEFAULT_EDIFACT_MSG_PURGEDAYS if defined($edifact_msg_days) && $edifact_msg_days == 0; |
239 |
@jobs_types = (DEFAULT_JOBS_PURGETYPES) if $jobs_days && @jobs_types == 0; |
|
|
240 |
$edifact_msg_days = DEFAULT_EDIFACT_MSG_PURGEDAYS if defined($edifact_msg_days) && $edifact_msg_days == 0; |
235 |
|
241 |
|
236 |
# Choose the number of days at which to purge unaccepted list invites: |
242 |
# Choose the number of days at which to purge unaccepted list invites: |
237 |
# - DAYS defined in the list-invites parameter is prioritised first |
243 |
# - DAYS defined in the list-invites parameter is prioritised first |
Lines 251-256
if ($help) {
Link Here
|
251 |
|
257 |
|
252 |
unless ( $sessions |
258 |
unless ( $sessions |
253 |
|| $zebraqueue_days |
259 |
|| $zebraqueue_days |
|
|
260 |
|| $zebraqueue_days_undone |
254 |
|| $mail |
261 |
|| $mail |
255 |
|| $purge_merged |
262 |
|| $purge_merged |
256 |
|| $pImport |
263 |
|| $pImport |
Lines 347-352
if ($zebraqueue_days) {
Link Here
|
347 |
} |
354 |
} |
348 |
} |
355 |
} |
349 |
|
356 |
|
|
|
357 |
if ($zebraqueue_days_undone) { |
358 |
my $count = 0; |
359 |
print "Zebraqueue undone purge triggered for $zebraqueue_days_undone days.\n" if $verbose; |
360 |
$sth = $dbh->prepare( |
361 |
q{ |
362 |
SELECT id,biblio_auth_number,server,time |
363 |
FROM zebraqueue |
364 |
WHERE done=0 AND time < date_sub(curdate(), INTERVAL ? DAY) |
365 |
} |
366 |
); |
367 |
$sth->execute($zebraqueue_days_undone) or die $dbh->errstr; |
368 |
$sth2 = $dbh->prepare(q{ DELETE FROM zebraqueue WHERE id=? }); |
369 |
while ( my $record = $sth->fetchrow_hashref ) { |
370 |
if ($confirm) { |
371 |
$sth2->execute( $record->{id} ) or die $dbh->errstr; |
372 |
} |
373 |
$count++; |
374 |
} |
375 |
if ($verbose) { |
376 |
say $confirm ? "$count records were deleted." : "$count records would have been deleted."; |
377 |
say "Done with zebraqueue undone purge."; |
378 |
} |
379 |
} |
380 |
|
350 |
if ($mail) { |
381 |
if ($mail) { |
351 |
my $count = 0; |
382 |
my $count = 0; |
352 |
print "Mail queue purge triggered for $mail days.\n" if $verbose; |
383 |
print "Mail queue purge triggered for $mail days.\n" if $verbose; |
353 |
- |
|
|