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