Lines 54-64
use Koha::Old::Patrons;
Link Here
|
54 |
use Koha::Patron::Debarments qw( DelDebarment ); |
54 |
use Koha::Patron::Debarments qw( DelDebarment ); |
55 |
use Koha::Patron::Messages; |
55 |
use Koha::Patron::Messages; |
56 |
use Koha::PseudonymizedTransactions; |
56 |
use Koha::PseudonymizedTransactions; |
|
|
57 |
use Koha::Statistics; |
57 |
use Koha::UploadedFiles; |
58 |
use Koha::UploadedFiles; |
58 |
|
59 |
|
59 |
sub usage { |
60 |
sub usage { |
60 |
print STDERR <<USAGE; |
61 |
print STDERR <<USAGE; |
61 |
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] [--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] |
62 |
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] |
62 |
|
63 |
|
63 |
-h --help prints this help message, and exits, ignoring all |
64 |
-h --help prints this help message, and exits, ignoring all |
64 |
other options |
65 |
other options |
Lines 107-112
Usage: $0 [-h|--help] [--confirm] [--sessions] [--sessdays DAYS] [-v|--verbose]
Link Here
|
107 |
--oauth-tokens Delete expired OAuth2 tokens |
108 |
--oauth-tokens Delete expired OAuth2 tokens |
108 |
--statistics DAYS Purge statistics entries more than DAYS days old. |
109 |
--statistics DAYS Purge statistics entries more than DAYS days old. |
109 |
This table is used to build reports, make sure you are aware of the consequences of this before using it! |
110 |
This table is used to build reports, make sure you are aware of the consequences of this before using it! |
|
|
111 |
--statistics-type TYPES What type of statistics to purge. Will purge all types if parameter is omitted. Repeatable. |
112 |
--statistics-type-pseudo Purges statistic types of "@Koha::Statistic::pseudonymization_types", unless more types are defined |
113 |
with --statistics-type. |
110 |
--deleted-catalog DAYS Purge catalog records deleted more then DAYS days ago |
114 |
--deleted-catalog DAYS Purge catalog records deleted more then DAYS days ago |
111 |
(from tables deleteditems, deletedbiblioitems, deletedbiblio_metadata and deletedbiblio). |
115 |
(from tables deleteditems, deletedbiblioitems, deletedbiblio_metadata and deletedbiblio). |
112 |
--deleted-patrons DAYS Purge patrons deleted more than DAYS days ago. |
116 |
--deleted-patrons DAYS Purge patrons deleted more than DAYS days ago. |
Lines 155-160
my $temp_uploads_days;
Link Here
|
155 |
my $uploads_missing; |
159 |
my $uploads_missing; |
156 |
my $oauth_tokens; |
160 |
my $oauth_tokens; |
157 |
my $pStatistics; |
161 |
my $pStatistics; |
|
|
162 |
my @statistics_types; |
163 |
my $statistics_type_pseudo; |
158 |
my $pDeletedCatalog; |
164 |
my $pDeletedCatalog; |
159 |
my $pDeletedPatrons; |
165 |
my $pDeletedPatrons; |
160 |
my $pOldIssues; |
166 |
my $pOldIssues; |
Lines 205-210
GetOptions(
Link Here
|
205 |
'uploads-missing:i' => \$uploads_missing, |
211 |
'uploads-missing:i' => \$uploads_missing, |
206 |
'oauth-tokens' => \$oauth_tokens, |
212 |
'oauth-tokens' => \$oauth_tokens, |
207 |
'statistics:i' => \$pStatistics, |
213 |
'statistics:i' => \$pStatistics, |
|
|
214 |
'statistics-type:s' => \@statistics_types, |
215 |
'statistics-type-pseudo:i' => \$statistics_type_pseudo, |
208 |
'deleted-catalog:i' => \$pDeletedCatalog, |
216 |
'deleted-catalog:i' => \$pDeletedCatalog, |
209 |
'deleted-patrons:i' => \$pDeletedPatrons, |
217 |
'deleted-patrons:i' => \$pDeletedPatrons, |
210 |
'old-issues:i' => \$pOldIssues, |
218 |
'old-issues:i' => \$pOldIssues, |
Lines 235-240
$jobs_days = DEFAULT_JOBS_PURGEDAYS if defined($jobs_days)
Link Here
|
235 |
@jobs_types = (DEFAULT_JOBS_PURGETYPES) if $jobs_days && @jobs_types == 0; |
243 |
@jobs_types = (DEFAULT_JOBS_PURGETYPES) if $jobs_days && @jobs_types == 0; |
236 |
$edifact_msg_days = DEFAULT_EDIFACT_MSG_PURGEDAYS if defined($edifact_msg_days) && $edifact_msg_days == 0; |
244 |
$edifact_msg_days = DEFAULT_EDIFACT_MSG_PURGEDAYS if defined($edifact_msg_days) && $edifact_msg_days == 0; |
237 |
|
245 |
|
|
|
246 |
@statistics_types = ( @statistics_types, @Koha::Statistic::pseudonymization_types ) if defined($statistics_type_pseudo); |
247 |
@statistics_types = keys %{ { map { $_, 1 } @statistics_types } }; # remove duplicate types |
248 |
|
238 |
# Choose the number of days at which to purge unaccepted list invites: |
249 |
# Choose the number of days at which to purge unaccepted list invites: |
239 |
# - DAYS defined in the list-invites parameter is prioritised first |
250 |
# - DAYS defined in the list-invites parameter is prioritised first |
240 |
# - PurgeListShareInvitesOlderThan system preference is prioritised second |
251 |
# - PurgeListShareInvitesOlderThan system preference is prioritised second |
Lines 602-612
if ($oauth_tokens) {
Link Here
|
602 |
} |
613 |
} |
603 |
|
614 |
|
604 |
if ($pStatistics) { |
615 |
if ($pStatistics) { |
605 |
print "Purging statistics older than $pStatistics days.\n" if $verbose; |
616 |
print "Purging statistics older than $pStatistics days" if $verbose; |
606 |
my $statistics = |
617 |
my $statistics_search_params = {}; |
607 |
Koha::Statistics->filter_by_last_update( { timestamp_column_name => 'datetime', days => $pStatistics } ); |
618 |
|
608 |
my $count = $statistics->count; |
619 |
if ( scalar(@statistics_types) ) { |
609 |
$statistics->delete if $confirm; |
620 |
print " with types \"" . join( ',', @statistics_types ) . "\".\n" if $verbose; |
|
|
621 |
$statistics_search_params->{type} = \@statistics_types; |
622 |
|
623 |
} |
624 |
print "\n" if $verbose; |
625 |
|
626 |
my $statistics = Koha::Statistics->search($statistics_search_params); |
627 |
my $filtered_statistics = |
628 |
$statistics->filter_by_last_update( { timestamp_column_name => 'datetime', days => $pStatistics } ); |
629 |
my $count = $filtered_statistics->count; |
630 |
$filtered_statistics->delete if $confirm; |
610 |
if ($verbose) { |
631 |
if ($verbose) { |
611 |
say $confirm |
632 |
say $confirm |
612 |
? sprintf( "Done with purging %d statistics", $count ) |
633 |
? sprintf( "Done with purging %d statistics", $count ) |