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 122-127 my $pDeletedPatrons; Link Here
122
my $pOldIssues;
125
my $pOldIssues;
123
my $pOldReserves;
126
my $pOldReserves;
124
my $pTransfers;
127
my $pTransfers;
128
my $pMessages;
125
129
126
GetOptions(
130
GetOptions(
127
    'h|help'            => \$help,
131
    'h|help'            => \$help,
Lines 134-139 GetOptions( Link Here
134
    'import:i'          => \$pImport,
138
    'import:i'          => \$pImport,
135
    'z3950'             => \$pZ3950,
139
    'z3950'             => \$pZ3950,
136
    'logs:i'            => \$pLogs,
140
    'logs:i'            => \$pLogs,
141
    'messages:i'        => \$pMessages,
137
    'fees:i'            => \$fees_days,
142
    'fees:i'            => \$fees_days,
138
    'searchhistory:i'   => \$pSearchhistory,
143
    'searchhistory:i'   => \$pSearchhistory,
139
    'list-invites:i'    => \$pListShareInvites,
144
    'list-invites:i'    => \$pListShareInvites,
Lines 163-168 $mail = DEFAULT_MAIL_PURGEDAYS if defined($mail) Link Here
163
$pSearchhistory    = DEFAULT_SEARCHHISTORY_PURGEDAYS      if defined($pSearchhistory)    && $pSearchhistory == 0;
168
$pSearchhistory    = DEFAULT_SEARCHHISTORY_PURGEDAYS      if defined($pSearchhistory)    && $pSearchhistory == 0;
164
$pListShareInvites = DEFAULT_SHARE_INVITATION_EXPIRY_DAYS if defined($pListShareInvites) && $pListShareInvites == 0;
169
$pListShareInvites = DEFAULT_SHARE_INVITATION_EXPIRY_DAYS if defined($pListShareInvites) && $pListShareInvites == 0;
165
$pDebarments       = DEFAULT_DEBARMENTS_PURGEDAYS         if defined($pDebarments)       && $pDebarments == 0;
170
$pDebarments       = DEFAULT_DEBARMENTS_PURGEDAYS         if defined($pDebarments)       && $pDebarments == 0;
171
$pMessages         = DEFAULT_MESSAGES_PURGEDAYS           if defined($pMessages)         && $pMessages == 0;
166
172
167
if ($help) {
173
if ($help) {
168
    usage(0);
174
    usage(0);
Lines 192-197 unless ( $sessions Link Here
192
    || $pOldIssues
198
    || $pOldIssues
193
    || $pOldReserves
199
    || $pOldReserves
194
    || $pTransfers
200
    || $pTransfers
201
    || $pMessages
195
) {
202
) {
196
    print "You did not specify any cleanup work for the script to do.\n\n";
203
    print "You did not specify any cleanup work for the script to do.\n\n";
197
    usage(1);
204
    usage(1);
Lines 293-298 if ($pLogs) { Link Here
293
    print "Done with purging action_logs.\n" if $verbose;
300
    print "Done with purging action_logs.\n" if $verbose;
294
}
301
}
295
302
303
if ($pMessages) {
304
    print "Purging records from messages.\n" if $verbose;
305
    $sth = $dbh->prepare(
306
        q{
307
            DELETE FROM messages
308
            WHERE message_date < date_sub(curdate(), INTERVAL ? DAY)
309
        }
310
    );
311
    $sth->execute($pMessages) or die $dbh->errstr;
312
    print "Done with purging messages.\n" if $verbose;
313
}
314
296
if ($fees_days) {
315
if ($fees_days) {
297
    print "Purging records from accountlines.\n" if $verbose;
316
    print "Purging records from accountlines.\n" if $verbose;
298
    purge_zero_balance_fees( $fees_days );
317
    purge_zero_balance_fees( $fees_days );
299
- 

Return to bug 24541