Skip to content

Commit

Permalink
Cs fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tersmitten committed Jan 17, 2020
1 parent a6c4ab2 commit 4c6e110
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 81 deletions.
2 changes: 1 addition & 1 deletion src/Model/Entity/QueuedTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ class QueuedTask extends Entity
'failed_count' => true,
'failure_message' => true,
'worker_key' => true,
'created' => true
'created' => true,
];
}
62 changes: 31 additions & 31 deletions src/Model/Table/QueuedTasksTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function createJob($taskName, array $data = null, string $notBefore = nul
$task = [
'task' => $taskName,
'data' => serialize($data),
'not_before' => $this->getDateTime()
'not_before' => $this->getDateTime(),
];

if (!empty($notBefore)) {
Expand All @@ -116,8 +116,8 @@ public function getLength($taskName = null): int
{
$findConf = [
'conditions' => [
'completed IS' => null
]
'completed IS' => null,
],
];
if ($taskName !== null) {
$findConf['conditions']['task'] = $taskName;
Expand All @@ -135,13 +135,13 @@ public function getTypes(): Query
{
$findCond = [
'fields' => [
'task'
'task',
],
'group' => [
'task'
'task',
],
'keyField' => 'task',
'valueField' => 'task'
'valueField' => 'task',
];

return $this->find('list', $findCond);
Expand Down Expand Up @@ -177,15 +177,15 @@ public function getStats(): Query
'num' => $query->func()->count('*'),
'alltime' => $alltime,
'runtime' => $runtime,
'fetchdelay' => $fetchdelay
'fetchdelay' => $fetchdelay,
];
},
'conditions' => [
'completed IS NOT' => null
'completed IS NOT' => null,
],
'group' => [
'task'
]
'task',
],
];

return $this->find('all', $options);
Expand Down Expand Up @@ -216,12 +216,12 @@ public function getFullStats($taskName = null): array
return [
'task',
'created',
'duration' => $runtime
'duration' => $runtime,
];
};

$conditions = [
'completed IS NOT' => null
'completed IS NOT' => null,
];
if ($taskName) {
$conditions['task'] = $taskName;
Expand Down Expand Up @@ -298,15 +298,15 @@ public function requestJob(array $capabilities, array $types = []): ?QueuedTask
$options = [
'conditions' => [
'completed IS' => null,
'OR' => []
'OR' => [],
],
'fields' => [
'age' => $age
'age' => $age,
],
'order' => [
'age' => 'ASC',
'id' => 'ASC'
]
'id' => 'ASC',
],
];

if ($types) {
Expand All @@ -323,17 +323,17 @@ public function requestJob(array $capabilities, array $types = []): ?QueuedTask
[
'OR' => [
'not_before <=' => $nowStr,
'not_before IS' => null
]
'not_before IS' => null,
],
],
[
'OR' => [
'fetched <' => $timeoutAt->subSeconds($task['timeout']),
'fetched IS' => null
]
]
'fetched IS' => null,
],
],
],
'failed_count <' => ($task['retries'] + 1)
'failed_count <' => ($task['retries'] + 1),
];
$options['conditions']['OR'][] = $tmp;
}
Expand All @@ -353,7 +353,7 @@ public function requestJob(array $capabilities, array $types = []): ?QueuedTask
/* @phan-suppress-next-line PhanPartialTypeMismatchArgument */
$task = $this->patchEntity($task, [
'worker_key' => $key,
'fetched' => $now
'fetched' => $now,
]);

return $this->saveOrFail($task);
Expand All @@ -375,7 +375,7 @@ public function requestJob(array $capabilities, array $types = []): ?QueuedTask
public function markJobDone(QueuedTask $task): bool
{
$fields = [
'completed' => $this->getDateTime()
'completed' => $this->getDateTime(),
];
$task = $this->patchEntity($task, $fields);

Expand All @@ -393,7 +393,7 @@ public function markJobFailed(QueuedTask $task, $failureMessage = null): bool
{
$fields = [
'failed_count' => $task->failed_count + 1,
'failure_message' => $failureMessage
'failure_message' => $failureMessage,
];
$task = $this->patchEntity($task, $fields);

Expand All @@ -414,10 +414,10 @@ public function reset($id = null): int
'fetched' => null,
'failed_count' => 0,
'worker_key' => null,
'failure_message' => null
'failure_message' => null,
];
$conditions = [
'completed IS' => null
'completed IS' => null,
];
if ($id) {
$conditions['id'] = $id;
Expand All @@ -439,11 +439,11 @@ public function rerun($taskName): int
'fetched' => null,
'failed_count' => 0,
'worker_key' => null,
'failure_message' => null
'failure_message' => null,
];
$conditions = [
'completed IS NOT' => null,
'task' => $taskName
'task' => $taskName,
];

return $this->updateAll($fields, $conditions);
Expand All @@ -461,7 +461,7 @@ public function cleanOldJobs(array $capabilities): void
list (, $name) = pluginSplit($task['name']);
$conditions = [
'task' => $name,
'completed <' => date('Y-m-d H:i:s', time() - (int)$task['cleanupTimeout'])
'completed <' => date('Y-m-d H:i:s', time() - (int)$task['cleanupTimeout']),
];
$this->deleteAll($conditions);
}
Expand All @@ -479,7 +479,7 @@ public function cleanFailedJobs(array $capabilities): void
list (, $name) = pluginSplit($task['name']);
$conditions = [
'task' => $name,
'failed_count >' => $task['retries']
'failed_count >' => $task['retries'],
];
$this->deleteAll($conditions);
}
Expand Down
28 changes: 14 additions & 14 deletions src/Shell/QueueShell.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use RuntimeException;
use Throwable;

declare(ticks = 1);
declare(ticks=1);

/**
* Main shell to init and run queue workers.
Expand Down Expand Up @@ -164,19 +164,19 @@ public function runworker(): void
if (function_exists('pcntl_signal')) {
pcntl_signal(SIGTERM, [
&$this,
'_exit'
'_exit',
]);
pcntl_signal(SIGINT, [
&$this,
'_exit'
'_exit',
]);
pcntl_signal(SIGTSTP, [
&$this,
'_exit'
'_exit',
]);
pcntl_signal(SIGQUIT, [
&$this,
'_exit'
'_exit',
]);
}
$this->_exit = false;
Expand Down Expand Up @@ -357,39 +357,39 @@ public function getOptionParser(): ConsoleOptionParser
* 'boolean' => true
* ),
*/
]
],
];
$subcommandParserFull = $subcommandParser;
$subcommandParserFull['options']['type'] = [
'short' => 't',
'help' => 'Type (comma separated list possible)',
'default' => null
'default' => null,
];

return parent::getOptionParser()->setDescription($this->getDescription())
->addSubcommand('clean', [
'help' => 'Remove old jobs (cleanup)',
'parser' => $subcommandParser
'parser' => $subcommandParser,
])
->addSubcommand('clean_failed', [
'help' => 'Remove old failed jobs (cleanup)',
'parser' => $subcommandParser
'parser' => $subcommandParser,
])
->addSubcommand('add', [
'help' => 'Add Job',
'parser' => $subcommandParser
'parser' => $subcommandParser,
])
->addSubcommand('stats', [
'help' => 'Stats',
'parser' => $subcommandParserFull
'parser' => $subcommandParserFull,
])
->addSubcommand('settings', [
'help' => 'Settings',
'parser' => $subcommandParserFull
'parser' => $subcommandParserFull,
])
->addSubcommand('runworker', [
'help' => 'Run Worker',
'parser' => $subcommandParserFull
'parser' => $subcommandParserFull,
]);
}

Expand Down Expand Up @@ -417,7 +417,7 @@ protected function _log($message, $pid = null, $addDetails = true): void
$message .= ' (pid ' . $pid . ')';
}
Log::write('info', $message, [
'scope' => 'queue'
'scope' => 'queue',
]);
}

Expand Down
Loading

0 comments on commit 4c6e110

Please sign in to comment.