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 204-209
GetOptions(
Link Here
|
204 |
'uploads-missing:i' => \$uploads_missing, |
210 |
'uploads-missing:i' => \$uploads_missing, |
205 |
'oauth-tokens' => \$oauth_tokens, |
211 |
'oauth-tokens' => \$oauth_tokens, |
206 |
'statistics:i' => \$pStatistics, |
212 |
'statistics:i' => \$pStatistics, |
|
|
213 |
'statistics-type:s' => \@statistics_types, |
214 |
'statistics-type-pseudo:i' => \$statistics_type_pseudo, |
207 |
'deleted-catalog:i' => \$pDeletedCatalog, |
215 |
'deleted-catalog:i' => \$pDeletedCatalog, |
208 |
'deleted-patrons:i' => \$pDeletedPatrons, |
216 |
'deleted-patrons:i' => \$pDeletedPatrons, |
209 |
'old-issues:i' => \$pOldIssues, |
217 |
'old-issues:i' => \$pOldIssues, |
Lines 234-239
$jobs_days = DEFAULT_JOBS_PURGEDAYS if defined($jobs_days)
Link Here
|
234 |
@jobs_types = (DEFAULT_JOBS_PURGETYPES) if $jobs_days && @jobs_types == 0; |
242 |
@jobs_types = (DEFAULT_JOBS_PURGETYPES) if $jobs_days && @jobs_types == 0; |
235 |
$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; |
236 |
|
244 |
|
|
|
245 |
@statistics_types = (@statistics_types, @Koha::Statistic::pseudonymization_types) if defined($statistics_type_pseudo); |
246 |
@statistics_types = keys %{{ map { $_, 1 } @statistics_types }}; # remove duplicate types |
247 |
|
237 |
# Choose the number of days at which to purge unaccepted list invites: |
248 |
# Choose the number of days at which to purge unaccepted list invites: |
238 |
# - DAYS defined in the list-invites parameter is prioritised first |
249 |
# - DAYS defined in the list-invites parameter is prioritised first |
239 |
# - PurgeListShareInvitesOlderThan system preference is prioritised second |
250 |
# - PurgeListShareInvitesOlderThan system preference is prioritised second |
Lines 603-613
if ($oauth_tokens) {
Link Here
|
603 |
} |
614 |
} |
604 |
|
615 |
|
605 |
if ($pStatistics) { |
616 |
if ($pStatistics) { |
606 |
print "Purging statistics older than $pStatistics days.\n" if $verbose; |
617 |
print "Purging statistics older than $pStatistics days" if $verbose; |
607 |
my $statistics = |
618 |
my $statistics_search_params = {}; |
608 |
Koha::Statistics->filter_by_last_update( { timestamp_column_name => 'datetime', days => $pStatistics } ); |
619 |
|
609 |
my $count = $statistics->count; |
620 |
if ( scalar(@statistics_types) ) { |
610 |
$statistics->delete if $confirm; |
621 |
print " with types \"".join(',', @statistics_types)."\".\n" if $verbose; |
|
|
622 |
$statistics_search_params->{type} = \@statistics_types; |
623 |
|
624 |
} |
625 |
print "\n" if $verbose; |
626 |
|
627 |
my $statistics = Koha::Statistics->search( $statistics_search_params ); |
628 |
my $filtered_statistics = |
629 |
$statistics->filter_by_last_update( { timestamp_column_name => 'datetime', days => $pStatistics } ); |
630 |
my $count = $filtered_statistics->count; |
631 |
$filtered_statistics->delete if $confirm; |
611 |
if ($verbose) { |
632 |
if ($verbose) { |
612 |
say $confirm |
633 |
say $confirm |
613 |
? sprintf( "Done with purging %d statistics", $count ) |
634 |
? sprintf( "Done with purging %d statistics", $count ) |