X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDB%2FManager%2FBackgroundJob.pm;h=1429a7856e00dd5d0c15072ea3fb79a1e3925fa3;hb=3a94f4d2dd9a835d4a7007e1b999ea00b3c4e1cd;hp=178f9d37a36493e38124e024e80036096a0e2225;hpb=782fd7884fb686cd2e336756dadeb4ab5d05a415;p=kivitendo-erp.git diff --git a/SL/DB/Manager/BackgroundJob.pm b/SL/DB/Manager/BackgroundJob.pm index 178f9d37a..1429a7856 100644 --- a/SL/DB/Manager/BackgroundJob.pm +++ b/SL/DB/Manager/BackgroundJob.pm @@ -2,8 +2,8 @@ package SL::DB::Manager::BackgroundJob; use strict; -use SL::DB::Helpers::Manager; -use base qw(SL::DB::Helpers::Manager); +use SL::DB::Helper::Manager; +use base qw(SL::DB::Helper::Manager); sub object_class { 'SL::DB::BackgroundJob' } @@ -15,8 +15,21 @@ sub cleanup { } sub get_all_need_to_run { - my $class = shift; - return $class->get_all(where => [ and => [ active => 1, next_run_at => { le => DateTime->now_local } ] ]); + my $class = shift; + + my $now = DateTime->now_local; + my @interval_args = (and => [ type => 'interval', + active => 1, + next_run_at => { le => $now } ]); + my @once_args = (and => [ type => 'once', + active => 1, + last_run_at => undef, + or => [ cron_spec => undef, + cron_spec => '', + next_run_at => undef, + next_run_at => { le => $now } ] ]); + + return $class->get_all(where => [ or => [ @interval_args, @once_args ] ]); } 1;