|
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 339-352
if ($pZ3950) {
Link Here
|
| 339 |
|
345 |
|
| 340 |
if ($pLogs) { |
346 |
if ($pLogs) { |
| 341 |
print "Purging records from action_logs.\n" if $verbose; |
347 |
print "Purging records from action_logs.\n" if $verbose; |
| 342 |
$sth = $dbh->prepare( |
348 |
my $log_query = q{ |
| 343 |
q{ |
|
|
| 344 |
DELETE FROM action_logs |
349 |
DELETE FROM action_logs |
| 345 |
WHERE timestamp < date_sub(curdate(), INTERVAL ? DAY) |
350 |
WHERE timestamp < date_sub(curdate(), INTERVAL ? DAY) |
| 346 |
} |
351 |
}; |
| 347 |
); |
352 |
my @query_params = (); |
|
|
353 |
if( @preserve_logs ){ |
| 354 |
$log_query .= " AND module NOT IN (" . join(',',('?') x @preserve_logs ) . ")"; |
| 355 |
push @query_params, @preserve_logs; |
| 356 |
} |
| 357 |
if( @log_modules ){ |
| 358 |
$log_query .= " AND module IN (" . join(',',('?') x @log_modules ) . ")"; |
| 359 |
push @query_params, @log_modules; |
| 360 |
} |
| 361 |
$sth = $dbh->prepare( $log_query ); |
| 348 |
if ( $confirm ) { |
362 |
if ( $confirm ) { |
| 349 |
$sth->execute($pLogs) or die $dbh->errstr; |
363 |
$sth->execute($pLogs, @query_params) or die $dbh->errstr; |
| 350 |
} |
364 |
} |
| 351 |
print "Done with purging action_logs.\n" if $verbose; |
365 |
print "Done with purging action_logs.\n" if $verbose; |
| 352 |
} |
366 |
} |
| 353 |
- |
|
|