diff --git a/.gitignore b/.gitignore index 7ddb2f4..efb728b 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,4 @@ Thumbs.db !empty /node_modules /vendor +composer.lock diff --git a/.travis/script.sh b/.travis/script.sh index 0f99915..6114497 100755 --- a/.travis/script.sh +++ b/.travis/script.sh @@ -31,9 +31,9 @@ elif [ "${PHP_MD}" = '1' ]; then vendor/bin/phpmd . text phpmd.xml --suffixes php --exclude "${excludePathsJoined}" || true; elif [ "${PHP_STAN}" = '1' ]; then - vendor/bin/phpstan analyse -c phpstan.neon -l 5 src/; + vendor/bin/phpstan analyse -c phpstan.neon -l 5 src/; elif [ "${PHP_PHAN}" = '1' ]; then - vendor/bin/phan; + vendor/bin/phan; elif [ "${PHP_COVERAGE}" = '1' ]; then vendor/bin/phpunit --coverage-clover=clover.xml; else diff --git a/src/Model/Table/QueuedTasksTable.php b/src/Model/Table/QueuedTasksTable.php index e4553c5..fe0c8ef 100644 --- a/src/Model/Table/QueuedTasksTable.php +++ b/src/Model/Table/QueuedTasksTable.php @@ -315,7 +315,7 @@ public function requestJob(array $capabilities, array $types = []): ?QueuedTask // Generate the task specific conditions. foreach ($capabilities as $task) { - list ($plugin, $name) = pluginSplit($task['name']); + list (, $name) = pluginSplit($task['name']); $timeoutAt = $now->copy(); $tmp = [ 'task' => $name, @@ -457,18 +457,14 @@ public function rerun($taskName): int */ public function cleanOldJobs(array $capabilities): void { - $conditions = []; - - // Generate the job specific conditions foreach ($capabilities as $task) { - list ($plugin, $name) = pluginSplit($task['name']); - $conditions['OR'][] = [ + list (, $name) = pluginSplit($task['name']); + $conditions = [ 'task' => $name, 'completed <' => date('Y-m-d H:i:s', time() - (int)$task['cleanupTimeout']) ]; + $this->deleteAll($conditions); } - - $this->deleteAll($conditions); } /** @@ -479,18 +475,14 @@ public function cleanOldJobs(array $capabilities): void */ public function cleanFailedJobs(array $capabilities): void { - $conditions = []; - - // Generate the job specific conditions. foreach ($capabilities as $task) { - list ($plugin, $name) = pluginSplit($task['name']); - $conditions['OR'][] = [ + list (, $name) = pluginSplit($task['name']); + $conditions = [ 'task' => $name, 'failed_count >' => $task['retries'] ]; + $this->deleteAll($conditions); } - - $this->deleteAll($conditions); } /**