Lines 80-85
Usage: $0 [-h|--help] [--confirm] [--sessions] [--sessdays DAYS] [-v|--verbose]
Link Here
|
80 |
amountoutstanding is 0 or NULL. |
80 |
amountoutstanding is 0 or NULL. |
81 |
In the case of --fees, DAYS must be greater than |
81 |
In the case of --fees, DAYS must be greater than |
82 |
or equal to 1. |
82 |
or equal to 1. |
|
|
83 |
--log_modules Specify which action log modules to trim. Repeatable. |
84 |
--preserve_logs Specify which action logs to exclude. Repeatable. |
83 |
--logs DAYS purge entries from action_logs older than DAYS days. |
85 |
--logs DAYS purge entries from action_logs older than DAYS days. |
84 |
Defaults to 180 days if no days specified. |
86 |
Defaults to 180 days if no days specified. |
85 |
--searchhistory DAYS purge entries from search_history older than DAYS days. |
87 |
--searchhistory DAYS purge entries from search_history older than DAYS days. |
Lines 148-153
my $pMessages;
Link Here
|
148 |
my $lock_days = C4::Context->preference('LockExpiredDelay'); |
150 |
my $lock_days = C4::Context->preference('LockExpiredDelay'); |
149 |
my $labels; |
151 |
my $labels; |
150 |
my $cards; |
152 |
my $cards; |
|
|
153 |
my @log_modules; |
154 |
my @preserve_logs; |
151 |
|
155 |
|
152 |
GetOptions( |
156 |
GetOptions( |
153 |
'h|help' => \$help, |
157 |
'h|help' => \$help, |
Lines 161-166
GetOptions(
Link Here
|
161 |
'import:i' => \$pImport, |
165 |
'import:i' => \$pImport, |
162 |
'z3950' => \$pZ3950, |
166 |
'z3950' => \$pZ3950, |
163 |
'logs:i' => \$pLogs, |
167 |
'logs:i' => \$pLogs, |
|
|
168 |
'log_module:s' => \@log_modules, |
169 |
'preserve_log:s' => \@preserve_logs, |
164 |
'messages:i' => \$pMessages, |
170 |
'messages:i' => \$pMessages, |
165 |
'fees:i' => \$fees_days, |
171 |
'fees:i' => \$fees_days, |
166 |
'searchhistory:i' => \$pSearchhistory, |
172 |
'searchhistory:i' => \$pSearchhistory, |
Lines 341-354
if ($pZ3950) {
Link Here
|
341 |
|
347 |
|
342 |
if ($pLogs) { |
348 |
if ($pLogs) { |
343 |
print "Purging records from action_logs.\n" if $verbose; |
349 |
print "Purging records from action_logs.\n" if $verbose; |
344 |
$sth = $dbh->prepare( |
350 |
my $log_query = q{ |
345 |
q{ |
|
|
346 |
DELETE FROM action_logs |
351 |
DELETE FROM action_logs |
347 |
WHERE timestamp < date_sub(curdate(), INTERVAL ? DAY) |
352 |
WHERE timestamp < date_sub(curdate(), INTERVAL ? DAY) |
348 |
} |
353 |
}; |
349 |
); |
354 |
my @query_params = (); |
|
|
355 |
if( @preserve_logs ){ |
356 |
$log_query .= " AND module NOT IN (" . join(',',('?') x @preserve_logs ) . ")"; |
357 |
push @query_params, @preserve_logs; |
358 |
} |
359 |
if( @log_modules ){ |
360 |
$log_query .= " AND module IN (" . join(',',('?') x @log_modules ) . ")"; |
361 |
push @query_params, @log_modules; |
362 |
} |
363 |
$sth = $dbh->prepare( $log_query ); |
350 |
if ( $confirm ) { |
364 |
if ( $confirm ) { |
351 |
$sth->execute($pLogs) or die $dbh->errstr; |
365 |
$sth->execute($pLogs, @query_params) or die $dbh->errstr; |
352 |
} |
366 |
} |
353 |
print "Done with purging action_logs.\n" if $verbose; |
367 |
print "Done with purging action_logs.\n" if $verbose; |
354 |
} |
368 |
} |
355 |
- |
|
|