View | Details | Raw Unified | Return to bug 34611
Collapse All | Expand All

(-)a/misc/maintenance/pseudonymize_statistics.pl (-1 / +19 lines)
Lines 22-27 use Pod::Usage qw( pod2usage ); Link Here
22
use Koha::DateUtils qw( dt_from_string format_sqldatetime );
22
use Koha::DateUtils qw( dt_from_string format_sqldatetime );
23
use Koha::Script;
23
use Koha::Script;
24
use Koha::Statistics;
24
use Koha::Statistics;
25
use Koha::PseudonymizedTransactions;
25
26
26
use C4::Context;
27
use C4::Context;
27
28
Lines 41-53 unless ( C4::Context->preference('Pseudonymization') ) { Link Here
41
}
42
}
42
43
43
$before //= format_sqldatetime( dt_from_string(), 'sql', undef, 1 );
44
$before //= format_sqldatetime( dt_from_string(), 'sql', undef, 1 );
45
print "Searching for statistics before $before\n" if $verbose;
44
46
45
my $statistics = Koha::Statistics->search( { datetime => { '<=' => $before } } );
47
my $statistics = Koha::Statistics->search( { datetime => { '<=' => $before } } );
48
print $statistics->count() . " statistics found\n" if $verbose;
49
50
51
my $existing_pseudo_stats = Koha::PseudonymizedTransactions->search( { datetime => { '<=' => $before } } )->count;
52
53
if ( $statistics->count && $existing_pseudo_stats ) {
54
    print "There are "
55
        . $statistics->count()
56
        . " statistics found, and $existing_pseudo_stats already in the database for the date provided.\n";
57
    print "You may have already run this script for the time period given.\n";
58
    print "Please enter 'Y' if you would like to continue:";
59
    chomp( my $continue = <> );
60
    exit unless uc($continue) eq 'Y';
61
}
62
46
63
47
while ( my $statistic = $statistics->next ) {
64
while ( my $statistic = $statistics->next ) {
48
    $statistic->pseudonymize();
65
    $statistic->pseudonymize();
49
}
66
}
50
67
68
print $statistics->count() . " statistics pseudonymized\n" if $verbose;
69
51
=head1 NAME
70
=head1 NAME
52
71
53
pseudonymize_statistics - This script pseudonymizes statistics before a given date, or now if no date passed.
72
pseudonymize_statistics - This script pseudonymizes statistics before a given date, or now if no date passed.
54
- 

Return to bug 34611