Lines 58-63
Usage: $0 [-h|--help] [--sessions] [--sessdays DAYS] [-v|--verbose] [--zebraqueu
Link Here
|
58 |
--merged purged completed entries from need_merge_authorities. |
58 |
--merged purged completed entries from need_merge_authorities. |
59 |
--import DAYS purge records from import tables older than DAYS days. |
59 |
--import DAYS purge records from import tables older than DAYS days. |
60 |
Defaults to 60 days if no days specified. |
60 |
Defaults to 60 days if no days specified. |
|
|
61 |
--z3950 purge records from import tables that are the result |
62 |
of z39.50 searches |
61 |
--logs DAYS purge entries from action_logs older than DAYS days. |
63 |
--logs DAYS purge entries from action_logs older than DAYS days. |
62 |
Defaults to 180 days if no days specified. |
64 |
Defaults to 180 days if no days specified. |
63 |
--searchhistory DAYS purge entries from search_history older than DAYS days. |
65 |
--searchhistory DAYS purge entries from search_history older than DAYS days. |
Lines 66-72
USAGE
Link Here
|
66 |
exit $_[0]; |
68 |
exit $_[0]; |
67 |
} |
69 |
} |
68 |
|
70 |
|
69 |
my ( $help, $sessions, $sess_days, $verbose, $zebraqueue_days, $mail, $purge_merged, $pImport, $pLogs, $pSearchhistory); |
71 |
my ( |
|
|
72 |
$help, $sessions, $sess_days, $verbose, |
73 |
$zebraqueue_days, $mail, $purge_merged, $pImport, |
74 |
$pLogs, $pSearchhistory, $pZ3950 |
75 |
); |
70 |
|
76 |
|
71 |
GetOptions( |
77 |
GetOptions( |
72 |
'h|help' => \$help, |
78 |
'h|help' => \$help, |
Lines 77-82
GetOptions(
Link Here
|
77 |
'zebraqueue:i' => \$zebraqueue_days, |
83 |
'zebraqueue:i' => \$zebraqueue_days, |
78 |
'merged' => \$purge_merged, |
84 |
'merged' => \$purge_merged, |
79 |
'import:i' => \$pImport, |
85 |
'import:i' => \$pImport, |
|
|
86 |
'z3950' => \$pZ3950, |
80 |
'logs:i' => \$pLogs, |
87 |
'logs:i' => \$pLogs, |
81 |
'searchhistory:i' => \$pSearchhistory, |
88 |
'searchhistory:i' => \$pSearchhistory, |
82 |
) || usage(1); |
89 |
) || usage(1); |
Lines 94-100
if ($help) {
Link Here
|
94 |
usage(0); |
101 |
usage(0); |
95 |
} |
102 |
} |
96 |
|
103 |
|
97 |
if ( !( $sessions || $zebraqueue_days || $mail || $purge_merged || $pImport || $pLogs || $pSearchhistory ) ) { |
104 |
unless ( $sessions |
|
|
105 |
|| $zebraqueue_days |
106 |
|| $mail |
107 |
|| $purge_merged |
108 |
|| $pImport |
109 |
|| $pLogs |
110 |
|| $pSearchhistory |
111 |
|| $pZ3950 ) |
112 |
{ |
98 |
print "You did not specify any cleanup work for the script to do.\n\n"; |
113 |
print "You did not specify any cleanup work for the script to do.\n\n"; |
99 |
usage(1); |
114 |
usage(1); |
100 |
} |
115 |
} |
Lines 172-177
if($pImport) {
Link Here
|
172 |
print "Done with purging import tables.\n" if $verbose; |
187 |
print "Done with purging import tables.\n" if $verbose; |
173 |
} |
188 |
} |
174 |
|
189 |
|
|
|
190 |
if($pZ3950) { |
191 |
print "Purging z39.50 records from import tables.\n" if $verbose; |
192 |
PurgeZ3950(); |
193 |
print "Done with purging z39.50 records from import tables.\n" if $verbose; |
194 |
} |
195 |
|
175 |
if($pLogs) { |
196 |
if($pLogs) { |
176 |
print "Purging records from action_logs.\n" if $verbose; |
197 |
print "Purging records from action_logs.\n" if $verbose; |
177 |
$sth = $dbh->prepare("DELETE FROM action_logs WHERE timestamp < date_sub(curdate(), interval ? DAY)"); |
198 |
$sth = $dbh->prepare("DELETE FROM action_logs WHERE timestamp < date_sub(curdate(), interval ? DAY)"); |
Lines 232-234
sub PurgeImportTables {
Link Here
|
232 |
ba.upload_timestamp < date_sub(curdate(), interval ? DAY)"); |
253 |
ba.upload_timestamp < date_sub(curdate(), interval ? DAY)"); |
233 |
$sth->execute($pImport) or die $dbh->errstr; |
254 |
$sth->execute($pImport) or die $dbh->errstr; |
234 |
} |
255 |
} |
235 |
- |
256 |
|
|
|
257 |
|
258 |
sub PurgeZ3950 { |
259 |
$sth = $dbh->prepare(q{ |
260 |
DELETE FROM import_batches WHERE batch_type = 'z3950' |
261 |
}); |
262 |
$sth->execute() or die $dbh->errstr; |
263 |
} |