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