1 package SL::BackgroundJob::CleanBackgroundJobHistory;
3 use parent qw(SL::BackgroundJob::Base);
5 use SL::DB::BackgroundJobHistory;
8 $_[0]->create_standard_job('0 3 * * *'); # daily at 3:00 am
15 my $options = $db_obj->data_as_hash;
16 $options->{retention_success} ||= 14;
17 $options->{retention_failure} ||= 3 * 30;
19 my $today = DateTime->today_local;
21 for my $status (qw(success failure)) {
22 SL::DB::Manager::BackgroundJobHistory->delete_all(where => [ status => $status,
23 run_at => { lt => $today->clone->subtract(days => $options->{"retention_${status}"}) } ]);
37 SL::BackgroundJob::CleanBackgroundJobHistory - Background job for
38 cleaning the history table of all executed jobs
42 This background job deletes old entries from the table
43 C<background_job_histories>. Each time a job is run an entry is
44 created in that table.
46 The associated C<SL::DB::BackgroundJob> instance's C<data> may be a
47 hash containing the retention periods for successful and failed
48 jobs. Both are the number of days a history entry is to be kept. C<<
49 $data->{retention_success} >> defaults to 14. C<<
50 $data->{retention_failure} >> defaults to 90.
52 The job is supposed to run once a day.
60 Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt>