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

(-)a/misc/cronjobs/cleanup_database.pl (-1 / +19 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 59-64 Usage: $0 [-h|--help] [--sessions] [--sessdays DAYS] [-v|--verbose] [--zebraqueu Link Here
59
   -m --mail DAYS     purge items from the mail queue that are older than DAYS days.
60
   -m --mail DAYS     purge items from the mail queue that are older than DAYS days.
60
                      Defaults to 30 days if no days specified.
61
                      Defaults to 30 days if no days specified.
61
   --merged           purged completed entries from need_merge_authorities.
62
   --merged           purged completed entries from need_merge_authorities.
63
   --messages DAYS    purge entries from messages table older than DAYS days.
64
                      Defaults to 365 days if no days specified.
62
   --import DAYS      purge records from import tables older than DAYS days.
65
   --import DAYS      purge records from import tables older than DAYS days.
63
                      Defaults to 60 days if no days specified.
66
                      Defaults to 60 days if no days specified.
64
   --z3950            purge records from import tables that are the result
67
   --z3950            purge records from import tables that are the result
Lines 109-114 my $temp_uploads; Link Here
109
my $temp_uploads_days;
112
my $temp_uploads_days;
110
my $uploads_missing;
113
my $uploads_missing;
111
my $oauth_tokens;
114
my $oauth_tokens;
115
my $pMessages;
112
116
113
GetOptions(
117
GetOptions(
114
    'h|help'            => \$help,
118
    'h|help'            => \$help,
Lines 121-126 GetOptions( Link Here
121
    'import:i'          => \$pImport,
125
    'import:i'          => \$pImport,
122
    'z3950'             => \$pZ3950,
126
    'z3950'             => \$pZ3950,
123
    'logs:i'            => \$pLogs,
127
    'logs:i'            => \$pLogs,
128
    'messages:i'        => \$pMessages,
124
    'fees:i'            => \$fees_days,
129
    'fees:i'            => \$fees_days,
125
    'searchhistory:i'   => \$pSearchhistory,
130
    'searchhistory:i'   => \$pSearchhistory,
126
    'list-invites:i'    => \$pListShareInvites,
131
    'list-invites:i'    => \$pListShareInvites,
Lines 144-149 $mail = DEFAULT_MAIL_PURGEDAYS if defined($mail) Link Here
144
$pSearchhistory    = DEFAULT_SEARCHHISTORY_PURGEDAYS      if defined($pSearchhistory)    && $pSearchhistory == 0;
149
$pSearchhistory    = DEFAULT_SEARCHHISTORY_PURGEDAYS      if defined($pSearchhistory)    && $pSearchhistory == 0;
145
$pListShareInvites = DEFAULT_SHARE_INVITATION_EXPIRY_DAYS if defined($pListShareInvites) && $pListShareInvites == 0;
150
$pListShareInvites = DEFAULT_SHARE_INVITATION_EXPIRY_DAYS if defined($pListShareInvites) && $pListShareInvites == 0;
146
$pDebarments       = DEFAULT_DEBARMENTS_PURGEDAYS         if defined($pDebarments)       && $pDebarments == 0;
151
$pDebarments       = DEFAULT_DEBARMENTS_PURGEDAYS         if defined($pDebarments)       && $pDebarments == 0;
152
$pMessages         = DEFAULT_MESSAGES_PURGEDAYS           if defined($pMessages)         && $pMessages == 0;
147
153
148
if ($help) {
154
if ($help) {
149
    usage(0);
155
    usage(0);
Lines 167-172 unless ( $sessions Link Here
167
    || $temp_uploads
173
    || $temp_uploads
168
    || defined $uploads_missing
174
    || defined $uploads_missing
169
    || $oauth_tokens
175
    || $oauth_tokens
176
    || $pMessages
170
) {
177
) {
171
    print "You did not specify any cleanup work for the script to do.\n\n";
178
    print "You did not specify any cleanup work for the script to do.\n\n";
172
    usage(1);
179
    usage(1);
Lines 268-273 if ($pLogs) { Link Here
268
    print "Done with purging action_logs.\n" if $verbose;
275
    print "Done with purging action_logs.\n" if $verbose;
269
}
276
}
270
277
278
if ($pMessages) {
279
    print "Purging records from messages.\n" if $verbose;
280
    $sth = $dbh->prepare(
281
        q{
282
            DELETE FROM messages
283
            WHERE message_date < date_sub(curdate(), INTERVAL ? DAY)
284
        }
285
    );
286
    $sth->execute($pMessages) or die $dbh->errstr;
287
    print "Done with purging messages.\n" if $verbose;
288
}
289
271
if ($fees_days) {
290
if ($fees_days) {
272
    print "Purging records from accountlines.\n" if $verbose;
291
    print "Purging records from accountlines.\n" if $verbose;
273
    purge_zero_balance_fees( $fees_days );
292
    purge_zero_balance_fees( $fees_days );
274
- 

Return to bug 24541