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 |
use Try::Tiny; |
37 |
use Try::Tiny; |
Lines 60-66
use Koha::UploadedFiles;
Link Here
|
60 |
|
61 |
|
61 |
sub usage { |
62 |
sub usage { |
62 |
print STDERR <<USAGE; |
63 |
print STDERR <<USAGE; |
63 |
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] [--statistics-type TYPE] [--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] |
64 |
Usage: $0 [-h|--help] [--confirm] [--sessions] [--sessdays DAYS] [-v|--verbose] [--zebraqueue DAYS] [-m|--mail] [--merged] [--import DAYS] [--logs DAYS] [--logs-batch ROWS] [--logs-sleep SECS] [--searchhistory DAYS] [--restrictions DAYS] [--all-restrictions] [--fees DAYS] [--temp-uploads] [--temp-uploads-days DAYS] [--uploads-missing 0|1 ] [--statistics DAYS] [--statistics-type TYPE] [--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] |
64 |
|
65 |
|
65 |
-h --help prints this help message, and exits, ignoring all |
66 |
-h --help prints this help message, and exits, ignoring all |
66 |
other options |
67 |
other options |
Lines 92-97
Usage: $0 [-h|--help] [--confirm] [--sessions] [--sessdays DAYS] [-v|--verbose]
Link Here
|
92 |
Defaults to 180 days if no days specified. |
93 |
Defaults to 180 days if no days specified. |
93 |
--logs-batch ROWS Delete action_logs rows in batches of ROWS. Ignored if --logs is not set. |
94 |
--logs-batch ROWS Delete action_logs rows in batches of ROWS. Ignored if --logs is not set. |
94 |
Defaults to 1000. |
95 |
Defaults to 1000. |
|
|
96 |
--logs-sleep SECS Sleeps for SECS seconds between each batch of action_logs rows deleted. Defaults to 3. |
95 |
--searchhistory DAYS purge entries from search_history older than DAYS days. |
97 |
--searchhistory DAYS purge entries from search_history older than DAYS days. |
96 |
Defaults to 30 days if no days specified |
98 |
Defaults to 30 days if no days specified |
97 |
--list-invites DAYS purge (unaccepted) list share invites older than DAYS days. |
99 |
--list-invites DAYS purge (unaccepted) list share invites older than DAYS days. |
Lines 182-187
my @jobs_types;
Link Here
|
182 |
my $reports; |
184 |
my $reports; |
183 |
my $edifact_msg_days; |
185 |
my $edifact_msg_days; |
184 |
my $logs_batch; |
186 |
my $logs_batch; |
|
|
187 |
my $logs_sleep = 3; |
185 |
|
188 |
|
186 |
my $command_line_options = join( " ", @ARGV ); |
189 |
my $command_line_options = join( " ", @ARGV ); |
187 |
cronlogaction( { info => $command_line_options } ); |
190 |
cronlogaction( { info => $command_line_options } ); |
Lines 233-238
GetOptions(
Link Here
|
233 |
'reports:i' => \$reports, |
236 |
'reports:i' => \$reports, |
234 |
'edifact-messages:i' => \$edifact_msg_days, |
237 |
'edifact-messages:i' => \$edifact_msg_days, |
235 |
'logs-batch:i' => \$logs_batch, |
238 |
'logs-batch:i' => \$logs_batch, |
|
|
239 |
'logs-sleep:i' => \$logs_sleep, |
236 |
) || usage(1); |
240 |
) || usage(1); |
237 |
|
241 |
|
238 |
# Use default values |
242 |
# Use default values |
Lines 248-253
$jobs_days = DEFAULT_JOBS_PURGEDAYS if defined($jobs_days)
Link Here
|
248 |
@jobs_types = (DEFAULT_JOBS_PURGETYPES) if $jobs_days && @jobs_types == 0; |
252 |
@jobs_types = (DEFAULT_JOBS_PURGETYPES) if $jobs_days && @jobs_types == 0; |
249 |
$edifact_msg_days = DEFAULT_EDIFACT_MSG_PURGEDAYS if defined($edifact_msg_days) && $edifact_msg_days == 0; |
253 |
$edifact_msg_days = DEFAULT_EDIFACT_MSG_PURGEDAYS if defined($edifact_msg_days) && $edifact_msg_days == 0; |
250 |
$logs_batch = DEFAULT_LOGS_BATCHSIZE if defined($logs_batch) && $logs_batch == 0; |
254 |
$logs_batch = DEFAULT_LOGS_BATCHSIZE if defined($logs_batch) && $logs_batch == 0; |
|
|
255 |
$logs_sleep = DEFAULT_LOGS_BATCHSLEEP if defined($logs_sleep) && $logs_sleep == 0; |
251 |
|
256 |
|
252 |
@statistics_types = ( @statistics_types, @Koha::Statistic::pseudonymization_types ) if defined($statistics_type_pseudo); |
257 |
@statistics_types = ( @statistics_types, @Koha::Statistic::pseudonymization_types ) if defined($statistics_type_pseudo); |
253 |
@statistics_types = keys %{ { map { $_, 1 } @statistics_types } }; # remove duplicate types |
258 |
@statistics_types = keys %{ { map { $_, 1 } @statistics_types } }; # remove duplicate types |
Lines 408-414
if ($pZ3950) {
Link Here
|
408 |
|
413 |
|
409 |
if ($pLogs) { |
414 |
if ($pLogs) { |
410 |
print "Purging records from action_logs.\n" if $verbose; |
415 |
print "Purging records from action_logs.\n" if $verbose; |
411 |
for (0..10000){ |
416 |
for ( 0 .. 10000 ) { |
412 |
$dbh->do(q{ INSERT INTO action_logs (user,timestamp) VALUES (52,"2022-01-01 09:00:00") }); |
417 |
$dbh->do(q{ INSERT INTO action_logs (user,timestamp) VALUES (52,"2022-01-01 09:00:00") }); |
413 |
$dbh->do(q{ UPDATE action_logs SET timestamp = "2020-01-01 10:00:00" ORDER BY action_id DESC LIMIT 1 }); |
418 |
$dbh->do(q{ UPDATE action_logs SET timestamp = "2020-01-01 10:00:00" ORDER BY action_id DESC LIMIT 1 }); |
414 |
} |
419 |
} |
Lines 440-446
if ($pLogs) {
Link Here
|
440 |
do { |
445 |
do { |
441 |
$sth->execute(@query_params) or die $dbh->errstr; |
446 |
$sth->execute(@query_params) or die $dbh->errstr; |
442 |
$rows_deleted = $sth->rows; |
447 |
$rows_deleted = $sth->rows; |
443 |
sleep 3; # Adjust sleep time as needed |
448 |
sleep $logs_sleep; |
444 |
} while ( $rows_deleted == $logs_batch ); |
449 |
} while ( $rows_deleted == $logs_batch ); |
445 |
} else { |
450 |
} else { |
446 |
$sth->execute(@query_params) or die $dbh->errstr; |
451 |
$sth->execute(@query_params) or die $dbh->errstr; |
447 |
- |
|
|