X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModule%2FAdmin%2FQueue.php;h=7f5329dbfe87aad6bf960f22325102ce2a9c2646;hb=2ce15cae1a41451b631b814c418b3b3b976d79d1;hp=705529166cf32f2d679c3dfc6dcda40359589ad2;hpb=5a01c537818565b832471b71e10d6ade6dc5b910;p=friendica.git diff --git a/src/Module/Admin/Queue.php b/src/Module/Admin/Queue.php index 705529166c..7f5329dbfe 100644 --- a/src/Module/Admin/Queue.php +++ b/src/Module/Admin/Queue.php @@ -1,66 +1,83 @@ -argc > 2 && $a->argv[2] == 'deferred'; - - // get jobs from the workerqueue table - if ($deferred) { - $condition = ["NOT `done` AND `next_try` > ?", DateTimeFormat::utcNow()]; - $sub_title = L10n::t('Inspect Deferred Worker Queue'); - $info = L10n::t("This page lists the deferred worker jobs. This are jobs that couldn't be executed at the first time."); - } else { - $condition = ["NOT `done` AND `next_try` < ?", DateTimeFormat::utcNow()]; - $sub_title = L10n::t('Inspect Worker Queue'); - $info = L10n::t('This page lists the currently queued worker jobs. These jobs are handled by the worker cronjob you\'ve set up during install.'); - } - - $entries = DBA::select('workerqueue', ['id', 'parameter', 'created', 'priority'], $condition, ['order' => ['priority']]); - - $r = []; - while ($entry = DBA::fetch($entries)) { - // fix GH-5469. ref: src/Core/Worker.php:217 - $entry['parameter'] = Arrays::recursiveImplode(json_decode($entry['parameter'], true), ': '); - $entry['created'] = DateTimeFormat::local($entry['created']); - $r[] = $entry; - } - DBA::close($entries); - - $t = Renderer::getMarkupTemplate('admin/queue.tpl'); - return Renderer::replaceMacros($t, [ - '$title' => L10n::t('Administration'), - '$page' => $sub_title, - '$count' => count($r), - '$id_header' => L10n::t('ID'), - '$param_header' => L10n::t('Job Parameters'), - '$created_header' => L10n::t('Created'), - '$prio_header' => L10n::t('Priority'), - '$info' => $info, - '$entries' => $r, - ]); - } -} +. + * + */ + +namespace Friendica\Module\Admin; + +use Friendica\Core\Renderer; +use Friendica\Database\DBA; +use Friendica\DI; +use Friendica\Module\BaseAdmin; +use Friendica\Util\Arrays; +use Friendica\Util\DateTimeFormat; + +/** + * Admin Inspect Queue Page + * + * Generates a page for the admin to have a look into the current queue of + * worker jobs. Shown are the parameters for the job and its priority. + * + * @return string + */ +class Queue extends BaseAdmin +{ + public static function content(array $parameters = []) + { + parent::content($parameters); + + $status = $parameters['status'] ?? ''; + + // get jobs from the workerqueue table + if ($status == 'deferred') { + $condition = ["NOT `done` AND `retrial` > ?", 0]; + $sub_title = DI::l10n()->t('Inspect Deferred Worker Queue'); + $info = DI::l10n()->t("This page lists the deferred worker jobs. This are jobs that couldn't be executed at the first time."); + } else { + $condition = ["NOT `done` AND `retrial` = ?", 0]; + $sub_title = DI::l10n()->t('Inspect Worker Queue'); + $info = DI::l10n()->t('This page lists the currently queued worker jobs. These jobs are handled by the worker cronjob you\'ve set up during install.'); + } + + // @TODO Move to Model\WorkerQueue::getEntries() + $entries = DBA::select('workerqueue', ['id', 'parameter', 'created', 'priority'], $condition, ['limit' => 999, 'order' => ['created']]); + + $r = []; + while ($entry = DBA::fetch($entries)) { + // fix GH-5469. ref: src/Core/Worker.php:217 + $entry['parameter'] = Arrays::recursiveImplode(json_decode($entry['parameter'], true), ': '); + $entry['created'] = DateTimeFormat::local($entry['created']); + $r[] = $entry; + } + DBA::close($entries); + + $t = Renderer::getMarkupTemplate('admin/queue.tpl'); + return Renderer::replaceMacros($t, [ + '$title' => DI::l10n()->t('Administration'), + '$page' => $sub_title, + '$count' => count($r), + '$id_header' => DI::l10n()->t('ID'), + '$param_header' => DI::l10n()->t('Job Parameters'), + '$created_header' => DI::l10n()->t('Created'), + '$prio_header' => DI::l10n()->t('Priority'), + '$info' => $info, + '$entries' => $r, + ]); + } +}