Skip to content

Commit

Permalink
Merge pull request #40 from Oefenweb/make-gc-more-efficient-3x
Browse files Browse the repository at this point in the history
Make gc more efficient
  • Loading branch information
tersmitten authored Oct 15, 2019
2 parents b53bebc + 0f1dbcb commit 90423a4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ Thumbs.db
!empty
/node_modules
/vendor
composer.lock
4 changes: 2 additions & 2 deletions .travis/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 7 additions & 15 deletions src/Model/Table/QueuedTasksTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
}

/**
Expand All @@ -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);
}

/**
Expand Down

0 comments on commit 90423a4

Please sign in to comment.