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

(-)a/misc/cronjobs/cleanup_database.pl (-2 / +46 lines)
Lines 55-61 use Koha::Patron::Messages; Link Here
55
55
56
sub usage {
56
sub usage {
57
    print STDERR <<USAGE;
57
    print STDERR <<USAGE;
58
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]
58
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]
59
59
60
   -h --help          prints this help message, and exits, ignoring all
60
   -h --help          prints this help message, and exits, ignoring all
61
                      other options
61
                      other options
Lines 107-112 Usage: $0 [-h|--help] [--confirm] [--sessions] [--sessdays DAYS] [-v|--verbose] Link Here
107
   --pseudo-transactions DAYS   Purge the pseudonymized transactions that have been originally created more than DAYS days ago
107
   --pseudo-transactions DAYS   Purge the pseudonymized transactions that have been originally created more than DAYS days ago
108
                                DAYS is optional and can be replaced by:
108
                                DAYS is optional and can be replaced by:
109
                                    --pseudo-transactions-from YYYY-MM-DD and/or --pseudo-transactions-to YYYY-MM-DD
109
                                    --pseudo-transactions-from YYYY-MM-DD and/or --pseudo-transactions-to YYYY-MM-DD
110
   --labels DAYS           Purge item label batches last added to more than DAYS days ago.
111
   --cards DAY             Purge card creator batches last added to more than DAYS days ago.
112
110
USAGE
113
USAGE
111
    exit $_[0];
114
    exit $_[0];
112
}
115
}
Lines 142-147 my $pOldReserves; Link Here
142
my $pTransfers;
145
my $pTransfers;
143
my ( $pPseudoTransactions, $pPseudoTransactionsFrom, $pPseudoTransactionsTo );
146
my ( $pPseudoTransactions, $pPseudoTransactionsFrom, $pPseudoTransactionsTo );
144
my $pMessages;
147
my $pMessages;
148
my $labels;
149
my $cards;
145
150
146
GetOptions(
151
GetOptions(
147
    'h|help'            => \$help,
152
    'h|help'            => \$help,
Lines 177-182 GetOptions( Link Here
177
    'pseudo-transactions:i'      => \$pPseudoTransactions,
182
    'pseudo-transactions:i'      => \$pPseudoTransactions,
178
    'pseudo-transactions-from:s' => \$pPseudoTransactionsFrom,
183
    'pseudo-transactions-from:s' => \$pPseudoTransactionsFrom,
179
    'pseudo-transactions-to:s'   => \$pPseudoTransactionsTo,
184
    'pseudo-transactions-to:s'   => \$pPseudoTransactionsTo,
185
    'labels'            => \$labels,
186
    'cards'             => \$cards,
180
) || usage(1);
187
) || usage(1);
181
188
182
# Use default values
189
# Use default values
Lines 222-227 unless ( $sessions Link Here
222
    || $pPseudoTransactionsFrom
229
    || $pPseudoTransactionsFrom
223
    || $pPseudoTransactionsTo
230
    || $pPseudoTransactionsTo
224
    || $pMessages
231
    || $pMessages
232
    || $labels
233
    || $cards
225
) {
234
) {
226
    print "You did not specify any cleanup work for the script to do.\n\n";
235
    print "You did not specify any cleanup work for the script to do.\n\n";
227
    usage(1);
236
    usage(1);
Lines 600-605 if (defined $pPseudoTransactions or $pPseudoTransactionsFrom or $pPseudoTransact Link Here
600
    }
609
    }
601
}
610
}
602
611
612
if ($labels) {
613
    print "Purging item label batches last added to more than $labels days ago.\n" if $verbose;
614
    $sth = $dbh->prepare(
615
        q{
616
        DELETE from creator_batches
617
        WHERE batch_id in
618
            (SELECT batch_id
619
            FROM (SELECT batch_id
620
                    FROM creator_batches
621
                    WHERE creator='labels'
622
                    GROUP BY batch_id
623
                    HAVING max(timestamp) < date_sub(curdate(),interval ? day)) a)
624
        }
625
    );
626
    $sth->execute($labels) or die $dbh->errstr;
627
    print "Done with purging item label batches last added to more than $labels days ago.\n" if $verbose;
628
}
629
630
if ($cards) {
631
    print "Purging card creator batches last added to more than $cards days ago.\n" if $verbose;
632
    $sth = $dbh->prepare(
633
        q{
634
        DELETE from creator_batches
635
        WHERE batch_id in
636
            (SELECT batch_id
637
            FROM (SELECT batch_id
638
                    FROM creator_batches
639
                    WHERE creator='patroncards'
640
                    GROUP BY batch_id
641
                    HAVING max(timestamp) < date_sub(curdate(),interval ? day)) a);
642
        }
643
    );
644
    $sth->execute($cards) or die $dbh->errstr;
645
    print "Done with purging card creator batches last added to more than $cards days ago.\n" if $verbose;
646
}
647
603
exit(0);
648
exit(0);
604
649
605
sub RemoveOldSessions {
650
sub RemoveOldSessions {
606
- 

Return to bug 15563