+ 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 } ] ]);
+ my @node_filter;
+
+ my $node_id = SL::System::TaskServer->node_id;
+ if ($::lx_office_conf{task_server}->{only_run_tasks_for_this_node}) {
+ @node_filter = (node_id => $node_id);
+ } else {
+ @node_filter = (
+ or => [
+ node_id => undef,
+ node_id => '',
+ node_id => $node_id,
+ ]);
+ }
+
+ return $class->get_all(query => [ or => [ @interval_args, @once_args ], @node_filter ]);