Lines 31-36
use constant DEFAULT_JOBS_PURGEDAYS => 1;
Link Here
|
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 |
use constant DEFAULT_LOGS_BATCHSIZE => 1000; |
|
|
34 |
use constant DEFAULT_LOGS_BATCHSLEEP => 3; |
34 |
|
35 |
|
35 |
use Getopt::Long qw( GetOptions ); |
36 |
use Getopt::Long qw( GetOptions ); |
36 |
|
37 |
|
Lines 90-95
Usage: $0 [-h|--help] [--confirm] [--sessions] [--sessdays DAYS] [-v|--verbose]
Link Here
|
90 |
Defaults to 180 days if no days specified. |
91 |
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 |
--logs-batch ROWS Delete action_logs rows in batches of ROWS. Ignored if --logs is not set. |
92 |
Defaults to 1000. |
93 |
Defaults to 1000. |
|
|
94 |
--logs-sleep SECS Sleeps for SECS seconds between each batch of action_logs rows deleted. Defaults to 3. |
93 |
--searchhistory DAYS purge entries from search_history older than DAYS days. |
95 |
--searchhistory DAYS purge entries from search_history older than DAYS days. |
94 |
Defaults to 30 days if no days specified |
96 |
Defaults to 30 days if no days specified |
95 |
--list-invites DAYS purge (unaccepted) list share invites older than DAYS days. |
97 |
--list-invites DAYS purge (unaccepted) list share invites older than DAYS days. |
Lines 175-180
my @jobs_types;
Link Here
|
175 |
my $reports; |
177 |
my $reports; |
176 |
my $edifact_msg_days; |
178 |
my $edifact_msg_days; |
177 |
my $logs_batch; |
179 |
my $logs_batch; |
|
|
180 |
my $logs_sleep = 3; |
178 |
|
181 |
|
179 |
my $command_line_options = join( " ", @ARGV ); |
182 |
my $command_line_options = join( " ", @ARGV ); |
180 |
|
183 |
|
Lines 223-228
GetOptions(
Link Here
|
223 |
'reports:i' => \$reports, |
226 |
'reports:i' => \$reports, |
224 |
'edifact-messages:i' => \$edifact_msg_days, |
227 |
'edifact-messages:i' => \$edifact_msg_days, |
225 |
'logs-batch:i' => \$logs_batch, |
228 |
'logs-batch:i' => \$logs_batch, |
|
|
229 |
'logs-sleep:i' => \$logs_sleep, |
226 |
) || usage(1); |
230 |
) || usage(1); |
227 |
|
231 |
|
228 |
# Use default values |
232 |
# Use default values |
Lines 238-243
$jobs_days = DEFAULT_JOBS_PURGEDAYS if defined($jobs_days)
Link Here
|
238 |
@jobs_types = (DEFAULT_JOBS_PURGETYPES) if $jobs_days && @jobs_types == 0; |
242 |
@jobs_types = (DEFAULT_JOBS_PURGETYPES) if $jobs_days && @jobs_types == 0; |
239 |
$edifact_msg_days = DEFAULT_EDIFACT_MSG_PURGEDAYS if defined($edifact_msg_days) && $edifact_msg_days == 0; |
243 |
$edifact_msg_days = DEFAULT_EDIFACT_MSG_PURGEDAYS if defined($edifact_msg_days) && $edifact_msg_days == 0; |
240 |
$logs_batch = DEFAULT_LOGS_BATCHSIZE if defined($logs_batch) && $logs_batch == 0; |
244 |
$logs_batch = DEFAULT_LOGS_BATCHSIZE if defined($logs_batch) && $logs_batch == 0; |
|
|
245 |
$logs_sleep = DEFAULT_LOGS_BATCHSLEEP if defined($logs_sleep) && $logs_sleep == 0; |
241 |
|
246 |
|
242 |
# Choose the number of days at which to purge unaccepted list invites: |
247 |
# Choose the number of days at which to purge unaccepted list invites: |
243 |
# - DAYS defined in the list-invites parameter is prioritised first |
248 |
# - DAYS defined in the list-invites parameter is prioritised first |
Lines 429-435
if ($pLogs) {
Link Here
|
429 |
do { |
434 |
do { |
430 |
$sth->execute(@query_params) or die $dbh->errstr; |
435 |
$sth->execute(@query_params) or die $dbh->errstr; |
431 |
$rows_deleted = $sth->rows; |
436 |
$rows_deleted = $sth->rows; |
432 |
sleep 3; # Adjust sleep time as needed |
437 |
sleep $logs_sleep; |
433 |
} while ( $rows_deleted == $logs_batch ); |
438 |
} while ( $rows_deleted == $logs_batch ); |
434 |
} else { |
439 |
} else { |
435 |
$sth->execute(@query_params) or die $dbh->errstr; |
440 |
$sth->execute(@query_params) or die $dbh->errstr; |
436 |
- |
|
|