Using query builder
This commit is contained in:
parent
caa8ca8ce5
commit
746e5afa8f
1 changed files with 10 additions and 10 deletions
|
@ -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');
|
||||||
|
|
Loading…
Add table
Reference in a new issue