Lines 113-118
Usage: $0 [-h|--help] [--confirm] [--sessions] [--sessdays DAYS] [-v|--verbose]
Link Here
|
113 |
--bg-days DAYS Purge all finished background jobs this many days old. Defaults to 1 if no DAYS provided. |
113 |
--bg-days DAYS Purge all finished background jobs this many days old. Defaults to 1 if no DAYS provided. |
114 |
--bg-type TYPES What type of background job to purge. Defaults to "update_elastic_index" if omitted |
114 |
--bg-type TYPES What type of background job to purge. Defaults to "update_elastic_index" if omitted |
115 |
Specifying "all" will purge all types. Repeatable. |
115 |
Specifying "all" will purge all types. Repeatable. |
|
|
116 |
--reports DAYS Purge reports data saved more than DAYS days ago. |
116 |
USAGE |
117 |
USAGE |
117 |
exit $_[0]; |
118 |
exit $_[0]; |
118 |
} |
119 |
} |
Lines 156-161
my @log_modules;
Link Here
|
156 |
my @preserve_logs; |
157 |
my @preserve_logs; |
157 |
my $background_days; |
158 |
my $background_days; |
158 |
my @background_types; |
159 |
my @background_types; |
|
|
160 |
my $reports; |
159 |
|
161 |
|
160 |
my $command_line_options = join(" ",@ARGV); |
162 |
my $command_line_options = join(" ",@ARGV); |
161 |
|
163 |
|
Lines 200-205
GetOptions(
Link Here
|
200 |
'return-claims' => \$return_claims, |
202 |
'return-claims' => \$return_claims, |
201 |
'bg-type:s' => \@background_types, |
203 |
'bg-type:s' => \@background_types, |
202 |
'bg-days:i' => \$background_days, |
204 |
'bg-days:i' => \$background_days, |
|
|
205 |
'reports:i' => \$reports, |
203 |
) || usage(1); |
206 |
) || usage(1); |
204 |
|
207 |
|
205 |
# Use default values |
208 |
# Use default values |
Lines 252-257
unless ( $sessions
Link Here
|
252 |
|| $cards |
255 |
|| $cards |
253 |
|| $return_claims |
256 |
|| $return_claims |
254 |
|| $background_days |
257 |
|| $background_days |
|
|
258 |
|| $reports |
255 |
) { |
259 |
) { |
256 |
print "You did not specify any cleanup work for the script to do.\n\n"; |
260 |
print "You did not specify any cleanup work for the script to do.\n\n"; |
257 |
usage(1); |
261 |
usage(1); |
Lines 702-707
if ($background_days) {
Link Here
|
702 |
} |
706 |
} |
703 |
} |
707 |
} |
704 |
|
708 |
|
|
|
709 |
if ($reports) { |
710 |
if ( $confirm ) { |
711 |
PurgeSavedReports($reports); |
712 |
} if ( $verbose ) { |
713 |
say "Purging reports data saved more than $reports days ago.\n"; |
714 |
} |
715 |
} |
716 |
|
705 |
cronlogaction({ action => 'End', info => "COMPLETED" }); |
717 |
cronlogaction({ action => 'End', info => "COMPLETED" }); |
706 |
|
718 |
|
707 |
exit(0); |
719 |
exit(0); |
Lines 840-842
sub DeleteSpecialHolidays {
Link Here
|
840 |
print "Removed $count unique holidays\n" if $verbose; |
852 |
print "Removed $count unique holidays\n" if $verbose; |
841 |
} |
853 |
} |
842 |
|
854 |
|
843 |
- |
855 |
sub PurgeSavedReports { |
|
|
856 |
my ( $reports ) = @_; |
857 |
|
858 |
my $sth = $dbh->prepare(q{ |
859 |
DELETE FROM saved_reports |
860 |
WHERE date(date_run) < DATE_SUB(CURDATE(),INTERVAL ? DAY ); |
861 |
}); |
862 |
$sth->execute( $reports ); |
863 |
} |