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

(-)a/misc/cronjobs/cleanup_database.pl (-1 / +21 lines)
Lines 23-28 use constant DEFAULT_ZEBRAQ_PURGEDAYS => 30; Link Here
23
use constant DEFAULT_MAIL_PURGEDAYS               => 30;
23
use constant DEFAULT_MAIL_PURGEDAYS               => 30;
24
use constant DEFAULT_IMPORT_PURGEDAYS             => 60;
24
use constant DEFAULT_IMPORT_PURGEDAYS             => 60;
25
use constant DEFAULT_LOGS_PURGEDAYS               => 180;
25
use constant DEFAULT_LOGS_PURGEDAYS               => 180;
26
use constant DEFAULT_MESSAGES_PURGEDAYS           => 365;
26
use constant DEFAULT_SEARCHHISTORY_PURGEDAYS      => 30;
27
use constant DEFAULT_SEARCHHISTORY_PURGEDAYS      => 30;
27
use constant DEFAULT_SHARE_INVITATION_EXPIRY_DAYS => 14;
28
use constant DEFAULT_SHARE_INVITATION_EXPIRY_DAYS => 14;
28
use constant DEFAULT_DEBARMENTS_PURGEDAYS         => 30;
29
use constant DEFAULT_DEBARMENTS_PURGEDAYS         => 30;
Lines 68-73 Usage: $0 [-h|--help] [--confirm] [--sessions] [--sessdays DAYS] [-v|--verbose] Link Here
68
   -m --mail DAYS     purge items from the mail queue that are older than DAYS days.
69
   -m --mail DAYS     purge items from the mail queue that are older than DAYS days.
69
                      Defaults to 30 days if no days specified.
70
                      Defaults to 30 days if no days specified.
70
   --merged           purged completed entries from need_merge_authorities.
71
   --merged           purged completed entries from need_merge_authorities.
72
   --messages DAYS    purge entries from messages table older than DAYS days.
73
                      Defaults to 365 days if no days specified.
71
   --import DAYS      purge records from import tables older than DAYS days.
74
   --import DAYS      purge records from import tables older than DAYS days.
72
                      Defaults to 60 days if no days specified.
75
                      Defaults to 60 days if no days specified.
73
   --z3950            purge records from import tables that are the result
76
   --z3950            purge records from import tables that are the result
Lines 137-142 my $pOldIssues; Link Here
137
my $pOldReserves;
140
my $pOldReserves;
138
my $pTransfers;
141
my $pTransfers;
139
my ( $pPseudoTransactions, $pPseudoTransactionsFrom, $pPseudoTransactionsTo );
142
my ( $pPseudoTransactions, $pPseudoTransactionsFrom, $pPseudoTransactionsTo );
143
my $pMessages;
140
144
141
GetOptions(
145
GetOptions(
142
    'h|help'            => \$help,
146
    'h|help'            => \$help,
Lines 150-155 GetOptions( Link Here
150
    'import:i'          => \$pImport,
154
    'import:i'          => \$pImport,
151
    'z3950'             => \$pZ3950,
155
    'z3950'             => \$pZ3950,
152
    'logs:i'            => \$pLogs,
156
    'logs:i'            => \$pLogs,
157
    'messages:i'        => \$pMessages,
153
    'fees:i'            => \$fees_days,
158
    'fees:i'            => \$fees_days,
154
    'searchhistory:i'   => \$pSearchhistory,
159
    'searchhistory:i'   => \$pSearchhistory,
155
    'list-invites:i'    => \$pListShareInvites,
160
    'list-invites:i'    => \$pListShareInvites,
Lines 182-187 $mail = DEFAULT_MAIL_PURGEDAYS if defined($mail) Link Here
182
$pSearchhistory    = DEFAULT_SEARCHHISTORY_PURGEDAYS      if defined($pSearchhistory)    && $pSearchhistory == 0;
187
$pSearchhistory    = DEFAULT_SEARCHHISTORY_PURGEDAYS      if defined($pSearchhistory)    && $pSearchhistory == 0;
183
$pListShareInvites = DEFAULT_SHARE_INVITATION_EXPIRY_DAYS if defined($pListShareInvites) && $pListShareInvites == 0;
188
$pListShareInvites = DEFAULT_SHARE_INVITATION_EXPIRY_DAYS if defined($pListShareInvites) && $pListShareInvites == 0;
184
$pDebarments       = DEFAULT_DEBARMENTS_PURGEDAYS         if defined($pDebarments)       && $pDebarments == 0;
189
$pDebarments       = DEFAULT_DEBARMENTS_PURGEDAYS         if defined($pDebarments)       && $pDebarments == 0;
190
$pMessages         = DEFAULT_MESSAGES_PURGEDAYS           if defined($pMessages)         && $pMessages == 0;
185
191
186
if ($help) {
192
if ($help) {
187
    usage(0);
193
    usage(0);
Lines 214-219 unless ( $sessions Link Here
214
    || defined $pPseudoTransactions
220
    || defined $pPseudoTransactions
215
    || $pPseudoTransactionsFrom
221
    || $pPseudoTransactionsFrom
216
    || $pPseudoTransactionsTo
222
    || $pPseudoTransactionsTo
223
    || $pMessages
217
) {
224
) {
218
    print "You did not specify any cleanup work for the script to do.\n\n";
225
    print "You did not specify any cleanup work for the script to do.\n\n";
219
    usage(1);
226
    usage(1);
Lines 334-339 if ($pLogs) { Link Here
334
    print "Done with purging action_logs.\n" if $verbose;
341
    print "Done with purging action_logs.\n" if $verbose;
335
}
342
}
336
343
344
if ($pMessages) {
345
    print "Purging records from messages.\n" if $verbose;
346
    $sth = $dbh->prepare(
347
        q{
348
            DELETE FROM messages
349
            WHERE message_date < date_sub(curdate(), INTERVAL ? DAY)
350
        }
351
    );
352
    if ( $confirm ) {
353
        $sth->execute($pMessages) or die $dbh->errstr;
354
    }
355
    print "Done with purging messages.\n" if $verbose;
356
}
357
337
if ($fees_days) {
358
if ($fees_days) {
338
    print "Purging records from accountlines.\n" if $verbose;
359
    print "Purging records from accountlines.\n" if $verbose;
339
    purge_zero_balance_fees( $fees_days ) if $confirm;
360
    purge_zero_balance_fees( $fees_days ) if $confirm;
340
- 

Return to bug 24541