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

(-)a/misc/cronjobs/cleanup_database.pl (-1 / +47 lines)
Lines 103-108 Usage: $0 [-h|--help] [--confirm] [--sessions] [--sessdays DAYS] [-v|--verbose] Link Here
103
   --pseudo-transactions DAYS   Purge the pseudonymized transactions that have been originally created more than DAYS days ago
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:
104
                                DAYS is optional and can be replaced by:
105
                                    --pseudo-transactions-from YYYY-MM-DD and/or --pseudo-transactions-to YYYY-MM-DD
105
                                    --pseudo-transactions-from YYYY-MM-DD and/or --pseudo-transactions-to YYYY-MM-DD
106
   --labels DAYS           Purge item label batches last added to more than DAYS days ago.
107
   --cards DAY             Purge card creator batches last added to more than DAYS days ago.
108
106
USAGE
109
USAGE
107
    exit $_[0];
110
    exit $_[0];
108
}
111
}
Lines 577-582 if (defined $pPseudoTransactions or $pPseudoTransactionsFrom or $pPseudoTransact Link Here
577
          ? sprintf "Done with purging %d pseudonymized transactions.", $count
580
          ? sprintf "Done with purging %d pseudonymized transactions.", $count
578
          : sprintf "%d pseudonymized transactions would have been purged.", $count;
581
          : sprintf "%d pseudonymized transactions would have been purged.", $count;
579
    }
582
    }
583
    $sth = $dbh->prepare(
584
        q{
585
            DELETE FROM branchtransfers
586
            WHERE datearrived < DATE_SUB(CURDATE(), INTERVAL ? DAY)
587
        }
588
    );
589
    $sth->execute($pTransfers);
590
    print "Done with purging transfers.\n" if $verbose;
591
}
592
593
if ($labels) {
594
    print "Purging item label batches last added to more than $labels days ago.\n" if $verbose;
595
    $sth = $dbh->prepare(
596
        q{
597
        DELETE from creator_batches
598
        WHERE batch_id in
599
            (SELECT batch_id
600
            FROM (SELECT batch_id
601
                    FROM creator_batches
602
                    WHERE creator='labels'
603
                    GROUP BY batch_id
604
                    HAVING max(timestamp) < date_sub(curdate(),interval ? day)) a)
605
        }
606
    );
607
    $sth->execute($labels) or die $dbh->errstr;
608
    print "Done with purging item label batches last added to more than $labels days ago.\n" if $verbose;
609
}
610
611
if ($cards) {
612
    print "Purging card creator batches last added to more than $cards days ago.\n" if $verbose;
613
    $sth = $dbh->prepare(
614
        q{
615
        DELETE from creator_batches
616
        WHERE batch_id in
617
            (SELECT batch_id
618
            FROM (SELECT batch_id
619
                    FROM creator_batches
620
                    WHERE creator='patroncards'
621
                    GROUP BY batch_id
622
                    HAVING max(timestamp) < date_sub(curdate(),interval ? day)) a);
623
        }
624
    );
625
    $sth->execute($cards) or die $dbh->errstr;
626
    print "Done with purging card creator batches last added to more than $cards days ago.\n" if $verbose;
580
}
627
}
581
628
582
exit(0);
629
exit(0);
583
- 

Return to bug 15563