Using query builder

This commit is contained in:
Axel 2021-12-20 22:14:49 +01:00
parent caa8ca8ce5
commit 746e5afa8f

View file

@ -51,16 +51,16 @@ class RunMonitoring extends Command
$rounds = $this->argument('rounds') ?? $this->rounds; $rounds = $this->argument('rounds') ?? $this->rounds;
// Getting pending tasks // Getting pending tasks
$tasks = app('db')->select(' $tasks = DB::table('tasks')
SELECT id, host, type, params ->where(function($query) {
FROM tasks $query->whereRaw('DATE_SUB(now(), INTERVAL frequency SECOND) > last_execution');
WHERE ( DATE_SUB(now(), INTERVAL frequency SECOND) > last_execution OR last_execution IS NULL ) $query->orWhereNull('last_execution');
AND active = 1 })
ORDER BY last_execution ASC ->where('active', 1)
LIMIT :limit ->orderBy('last_execution', 'ASC')
', [ ->take($rounds)
'limit' => $rounds ->get()
]); ;
if (is_null($tasks) || count($tasks) == 0) { if (is_null($tasks) || count($tasks) == 0) {
$this->info('No task to process, going back to sleep'); $this->info('No task to process, going back to sleep');