1 package SL::DB::Manager::BackgroundJob;
5 use SL::DB::Helper::Manager;
6 use base qw(SL::DB::Helper::Manager);
8 sub object_class { 'SL::DB::BackgroundJob' }
10 __PACKAGE__->make_manager_methods;
14 $class->delete_all(where => [ and => [ type => 'once', last_run_at => { lt => DateTime->now_local->subtract(days => '1') } ] ]);
17 sub get_all_need_to_run {
20 my $now = DateTime->now_local;
21 my @interval_args = (and => [ type => 'interval',
23 next_run_at => { le => $now } ]);
24 my @once_args = (and => [ type => 'once',
27 or => [ cron_spec => undef,
30 next_run_at => { le => $now } ] ]);
32 return $class->get_all(where => [ or => [ @interval_args, @once_args ] ]);