Lines 96-101
Usage: $0 [-h|--help] [--sessions] [--sessdays DAYS] [-v|--verbose] [--zebraqueu
Link Here
|
96 |
--old-issues DAYS Purge checkouts (old_issues) returned more than DAYS days ago. |
96 |
--old-issues DAYS Purge checkouts (old_issues) returned more than DAYS days ago. |
97 |
--old-reserves DAYS Purge reserves (old_reserves) more than DAYS old. |
97 |
--old-reserves DAYS Purge reserves (old_reserves) more than DAYS old. |
98 |
--transfers DAYS Purge transfers completed more than DAYS day ago. |
98 |
--transfers DAYS Purge transfers completed more than DAYS day ago. |
|
|
99 |
--pseudo-patrons DAYS Purge the pseudonymized patrons that have been originally enrolled more than DAYS days ago |
100 |
DAYS is optional and can be replaced by |
101 |
--pseudo-patrons-from YYYY-MM-DD (iso formatted date, or as the 'dateformat' system preference is set |
102 |
and/or --pseudo-patrons-to YYYY-MM-DD |
103 |
--pseudo-transactions DAYS Purge the pseudonymized transactions that have been originally created more than DAYS days ago |
104 |
DAYS is optional and can be replaced by: |
105 |
--pseudo-transactions-from YYYY-MM-DD and/or --pseudo-patrons-to YYYY-MM-DD |
99 |
USAGE |
106 |
USAGE |
100 |
exit $_[0]; |
107 |
exit $_[0]; |
101 |
} |
108 |
} |
Lines 128-133
my $pDeletedPatrons;
Link Here
|
128 |
my $pOldIssues; |
135 |
my $pOldIssues; |
129 |
my $pOldReserves; |
136 |
my $pOldReserves; |
130 |
my $pTransfers; |
137 |
my $pTransfers; |
|
|
138 |
my ( $pPseudoPatrons, $pPseudoPatronsFrom, $pPseudoPatronsTo ); |
139 |
my ( $pPseudoTransactions, $pPseudoTransactionsFrom, $pPseudoTransactionsTo ); |
131 |
|
140 |
|
132 |
GetOptions( |
141 |
GetOptions( |
133 |
'h|help' => \$help, |
142 |
'h|help' => \$help, |
Lines 157-163
GetOptions(
Link Here
|
157 |
'deleted-patrons:i' => \$pDeletedPatrons, |
166 |
'deleted-patrons:i' => \$pDeletedPatrons, |
158 |
'old-issues:i' => \$pOldIssues, |
167 |
'old-issues:i' => \$pOldIssues, |
159 |
'old-reserves:i' => \$pOldReserves, |
168 |
'old-reserves:i' => \$pOldReserves, |
160 |
'transfers:i' => \$pTransfers, |
169 |
'transfers:i' => \$pTransfers, |
|
|
170 |
'pseudo-patrons:i' => \$pPseudoPatrons, |
171 |
'pseudo-patrons-from:s' => \$pPseudoPatronsFrom, |
172 |
'pseudo-patrons-to:s' => \$pPseudoPatronsTo, |
173 |
'pseudo-transactions:i' => \$pPseudoTransactions, |
174 |
'pseudo-transactions-from:s' => \$pPseudoTransactionsFrom, |
175 |
'pseudo-transactions-to:s' => \$pPseudoTransactionsTo, |
161 |
) || usage(1); |
176 |
) || usage(1); |
162 |
|
177 |
|
163 |
# Use default values |
178 |
# Use default values |
Lines 198-203
unless ( $sessions
Link Here
|
198 |
|| $pOldIssues |
213 |
|| $pOldIssues |
199 |
|| $pOldReserves |
214 |
|| $pOldReserves |
200 |
|| $pTransfers |
215 |
|| $pTransfers |
|
|
216 |
|| defined $pPseudoPatrons |
217 |
|| defined $pPseudoTransactions |
201 |
) { |
218 |
) { |
202 |
print "You did not specify any cleanup work for the script to do.\n\n"; |
219 |
print "You did not specify any cleanup work for the script to do.\n\n"; |
203 |
usage(1); |
220 |
usage(1); |
Lines 430-435
if ($pTransfers) {
Link Here
|
430 |
print "Done with purging transfers.\n" if $verbose; |
447 |
print "Done with purging transfers.\n" if $verbose; |
431 |
} |
448 |
} |
432 |
|
449 |
|
|
|
450 |
if (defined $pPseudoPatrons) { |
451 |
print "Purging pseudonymized patrons older than $pPseudoPatrons days.\n" if $verbose; |
452 |
my $anonymized_patrons = Koha::Anonymized::Patrons->filter_by_last_update( |
453 |
{ |
454 |
timestamp_column_name => 'dateenrolled', |
455 |
( $pPseudoPatrons ? ( days => $pPseudoPatrons ) : () ), |
456 |
( $pPseudoPatronsFrom ? ( from => $pPseudoPatronsFrom ) : () ), |
457 |
( $pPseudoPatronsTo ? ( to => $pPseudoPatronsTo ) : () ), |
458 |
} |
459 |
)->delete; |
460 |
print "Done with purging pseudonymized patrons.\n" if $verbose; |
461 |
} |
462 |
|
463 |
if (defined $pPseudoTransactions) { |
464 |
print "Purging pseudonymized transactions older than $pPseudoTransactions days.\n" if $verbose; |
465 |
Koha::Anonymized::Transactions->filter_by_last_update( |
466 |
{ |
467 |
timestamp_column_name => 'datetime', |
468 |
( $pPseudoTransactions ? ( days => $pPseudoTransactions ) : () ), |
469 |
( $pPseudoTransactionsFrom ? ( from => $pPseudoTransactionsFrom ) : () ), |
470 |
( $pPseudoTransactionsTo ? ( to => $pPseudoTransactionsTo ) : () ), |
471 |
} |
472 |
)->delete; |
473 |
print "Done with purging pseudonymized transactions.\n" if $verbose; |
474 |
} |
475 |
|
433 |
exit(0); |
476 |
exit(0); |
434 |
|
477 |
|
435 |
sub RemoveOldSessions { |
478 |
sub RemoveOldSessions { |