Lines 30-35
use constant DEFAULT_DEBARMENTS_PURGEDAYS => 30;
Link Here
|
30 |
use constant DEFAULT_JOBS_PURGEDAYS => 1; |
30 |
use constant DEFAULT_JOBS_PURGEDAYS => 1; |
31 |
use constant DEFAULT_JOBS_PURGETYPES => qw{ update_elastic_index }; |
31 |
use constant DEFAULT_JOBS_PURGETYPES => qw{ update_elastic_index }; |
32 |
use constant DEFAULT_EDIFACT_MSG_PURGEDAYS => 365; |
32 |
use constant DEFAULT_EDIFACT_MSG_PURGEDAYS => 365; |
|
|
33 |
use constant DEFAULT_LOGS_BATCHSIZE => 1000; |
33 |
|
34 |
|
34 |
use Getopt::Long qw( GetOptions ); |
35 |
use Getopt::Long qw( GetOptions ); |
35 |
|
36 |
|
Lines 87-92
Usage: $0 [-h|--help] [--confirm] [--sessions] [--sessdays DAYS] [-v|--verbose]
Link Here
|
87 |
--log-action Specify which action log action entries to trim. Repeatable. |
88 |
--log-action Specify which action log action entries to trim. Repeatable. |
88 |
--logs DAYS purge entries from action_logs older than DAYS days. |
89 |
--logs DAYS purge entries from action_logs older than DAYS days. |
89 |
Defaults to 180 days if no days specified. |
90 |
Defaults to 180 days if no days specified. |
|
|
91 |
--logs-batch ROWS Delete action_logs rows in batches of ROWS. Ignored if --logs is not set. |
92 |
Defaults to 1000. |
90 |
--searchhistory DAYS purge entries from search_history older than DAYS days. |
93 |
--searchhistory DAYS purge entries from search_history older than DAYS days. |
91 |
Defaults to 30 days if no days specified |
94 |
Defaults to 30 days if no days specified |
92 |
--list-invites DAYS purge (unaccepted) list share invites older than DAYS |
95 |
--list-invites DAYS purge (unaccepted) list share invites older than DAYS |
Lines 168-173
my $jobs_days;
Link Here
|
168 |
my @jobs_types; |
171 |
my @jobs_types; |
169 |
my $reports; |
172 |
my $reports; |
170 |
my $edifact_msg_days; |
173 |
my $edifact_msg_days; |
|
|
174 |
my $logs_batch; |
171 |
|
175 |
|
172 |
my $command_line_options = join(" ",@ARGV); |
176 |
my $command_line_options = join(" ",@ARGV); |
173 |
|
177 |
|
Lines 215-220
GetOptions(
Link Here
|
215 |
'jobs-days:i' => \$jobs_days, |
219 |
'jobs-days:i' => \$jobs_days, |
216 |
'reports:i' => \$reports, |
220 |
'reports:i' => \$reports, |
217 |
'edifact-messages:i' => \$edifact_msg_days, |
221 |
'edifact-messages:i' => \$edifact_msg_days, |
|
|
222 |
'logs-batch:i' => \$logs_batch, |
218 |
) || usage(1); |
223 |
) || usage(1); |
219 |
|
224 |
|
220 |
# Use default values |
225 |
# Use default values |
Lines 230-235
$pMessages = DEFAULT_MESSAGES_PURGEDAYS if defined($pMessages)
Link Here
|
230 |
$jobs_days = DEFAULT_JOBS_PURGEDAYS if defined($jobs_days) && $jobs_days == 0; |
235 |
$jobs_days = DEFAULT_JOBS_PURGEDAYS if defined($jobs_days) && $jobs_days == 0; |
231 |
@jobs_types = (DEFAULT_JOBS_PURGETYPES) if $jobs_days && @jobs_types == 0; |
236 |
@jobs_types = (DEFAULT_JOBS_PURGETYPES) if $jobs_days && @jobs_types == 0; |
232 |
$edifact_msg_days = DEFAULT_EDIFACT_MSG_PURGEDAYS if defined($edifact_msg_days) && $edifact_msg_days == 0; |
237 |
$edifact_msg_days = DEFAULT_EDIFACT_MSG_PURGEDAYS if defined($edifact_msg_days) && $edifact_msg_days == 0; |
|
|
238 |
$logs_batch = DEFAULT_LOGS_BATCHSIZE if defined($logs_batch) && $logs_batch == 0; |
233 |
|
239 |
|
234 |
if ($help) { |
240 |
if ($help) { |
235 |
usage(0); |
241 |
usage(0); |
Lines 393-401
if ($pLogs) {
Link Here
|
393 |
$log_query .= " AND action IN (" . join(',',('?') x @log_actions ) . ")"; |
399 |
$log_query .= " AND action IN (" . join(',',('?') x @log_actions ) . ")"; |
394 |
push @query_params, @log_actions; |
400 |
push @query_params, @log_actions; |
395 |
} |
401 |
} |
|
|
402 |
if( $logs_batch ){ |
403 |
$log_query .= " LIMIT ?"; |
404 |
push @query_params, $logs_batch; |
405 |
} |
396 |
$sth = $dbh->prepare( $log_query ); |
406 |
$sth = $dbh->prepare( $log_query ); |
397 |
if ( $confirm ) { |
407 |
if ( $confirm ) { |
398 |
$sth->execute($pLogs, @query_params) or die $dbh->errstr; |
408 |
if ( $logs_batch ) { |
|
|
409 |
my $counter = 0; |
410 |
my $rows = 0; |
411 |
while ( $counter <= $rows ) { |
412 |
$sth->execute($pLogs, @query_params) or die $dbh->errstr; |
413 |
sleep 3; |
414 |
$rows += $sth->rows; |
415 |
$counter += $logs_batch; |
416 |
} |
417 |
} else { |
418 |
$sth->execute($pLogs, @query_params) or die $dbh->errstr; |
419 |
} |
399 |
} |
420 |
} |
400 |
print "Done with purging action_logs.\n" if $verbose; |
421 |
print "Done with purging action_logs.\n" if $verbose; |
401 |
} |
422 |
} |
402 |
- |
|
|