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

(-)a/misc/cronjobs/cleanup_database.pl (-1 / +21 lines)
Lines 113-118 Usage: $0 [-h|--help] [--confirm] [--sessions] [--sessdays DAYS] [-v|--verbose] Link Here
113
   --jobs-days DAYS        Purge all finished background jobs this many days old. Defaults to 1 if no DAYS provided.
113
   --jobs-days DAYS        Purge all finished background jobs this many days old. Defaults to 1 if no DAYS provided.
114
   --jobs-type TYPES       What type of background job to purge. Defaults to "update_elastic_index" if omitted
114
   --jobs-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 $jobs_days;
158
my $jobs_days;
158
my @jobs_types;
159
my @jobs_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
    'jobs-type:s'       => \@jobs_types,
203
    'jobs-type:s'       => \@jobs_types,
202
    'jobs-days:i'       => \$jobs_days,
204
    'jobs-days:i'       => \$jobs_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
    || $jobs_days
257
    || $jobs_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 713-718 if ($jobs_days) { Link Here
713
    }
717
    }
714
}
718
}
715
719
720
if ($reports) {
721
    if ( $confirm ) {
722
        PurgeSavedReports($reports);
723
    } if ( $verbose ) {
724
        say "Purging reports data saved more than $reports days ago.\n";
725
    }
726
}
727
716
cronlogaction({ action => 'End', info => "COMPLETED" });
728
cronlogaction({ action => 'End', info => "COMPLETED" });
717
729
718
exit(0);
730
exit(0);
Lines 851-853 sub DeleteSpecialHolidays { Link Here
851
    print "Removed $count unique holidays\n" if $verbose;
863
    print "Removed $count unique holidays\n" if $verbose;
852
}
864
}
853
865
854
- 
866
sub PurgeSavedReports {
867
    my ( $reports ) = @_;
868
869
    my $sth = $dbh->prepare(q{
870
            DELETE FROM saved_reports
871
            WHERE date(date_run) < DATE_SUB(CURDATE(),INTERVAL ? DAY );
872
        });
873
    $sth->execute( $reports );
874
}

Return to bug 17350