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

(-)a/misc/cronjobs/cleanup_database.pl (-1 / +47 lines)
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 598-603 if (defined $pPseudoTransactions or $pPseudoTransactionsFrom or $pPseudoTransact Link Here
598
          ? sprintf "Done with purging %d pseudonymized transactions.", $count
601
          ? sprintf "Done with purging %d pseudonymized transactions.", $count
599
          : sprintf "%d pseudonymized transactions would have been purged.", $count;
602
          : sprintf "%d pseudonymized transactions would have been purged.", $count;
600
    }
603
    }
604
    $sth = $dbh->prepare(
605
        q{
606
            DELETE FROM branchtransfers
607
            WHERE datearrived < DATE_SUB(CURDATE(), INTERVAL ? DAY)
608
        }
609
    );
610
    $sth->execute($pTransfers);
611
    print "Done with purging transfers.\n" if $verbose;
612
}
613
614
if ($labels) {
615
    print "Purging item label batches last added to more than $labels days ago.\n" if $verbose;
616
    $sth = $dbh->prepare(
617
        q{
618
        DELETE from creator_batches
619
        WHERE batch_id in
620
            (SELECT batch_id
621
            FROM (SELECT batch_id
622
                    FROM creator_batches
623
                    WHERE creator='labels'
624
                    GROUP BY batch_id
625
                    HAVING max(timestamp) < date_sub(curdate(),interval ? day)) a)
626
        }
627
    );
628
    $sth->execute($labels) or die $dbh->errstr;
629
    print "Done with purging item label batches last added to more than $labels days ago.\n" if $verbose;
630
}
631
632
if ($cards) {
633
    print "Purging card creator batches last added to more than $cards days ago.\n" if $verbose;
634
    $sth = $dbh->prepare(
635
        q{
636
        DELETE from creator_batches
637
        WHERE batch_id in
638
            (SELECT batch_id
639
            FROM (SELECT batch_id
640
                    FROM creator_batches
641
                    WHERE creator='patroncards'
642
                    GROUP BY batch_id
643
                    HAVING max(timestamp) < date_sub(curdate(),interval ? day)) a);
644
        }
645
    );
646
    $sth->execute($cards) or die $dbh->errstr;
647
    print "Done with purging card creator batches last added to more than $cards days ago.\n" if $verbose;
601
}
648
}
602
649
603
exit(0);
650
exit(0);
604
- 

Return to bug 15563