3 namespace Friendica\Module\Admin;
\r
5 use Friendica\Core\L10n;
\r
6 use Friendica\Core\Renderer;
\r
7 use Friendica\Database\DBA;
\r
8 use Friendica\Module\BaseAdminModule;
\r
9 use Friendica\Util\Arrays;
\r
10 use Friendica\Util\DateTimeFormat;
\r
13 * @brief Admin Inspect Queue Page
\r
15 * Generates a page for the admin to have a look into the current queue of
\r
16 * worker jobs. Shown are the parameters for the job and its priority.
\r
20 class Queue extends BaseAdminModule
\r
22 public static function content()
\r
26 $a = self::getApp();
\r
28 // @TODO: Replace with parameter from router
\r
29 $deferred = $a->argc > 2 && $a->argv[2] == 'deferred';
\r
31 // get jobs from the workerqueue table
\r
33 $condition = ["NOT `done` AND `next_try` > ?", DateTimeFormat::utcNow()];
\r
34 $sub_title = L10n::t('Inspect Deferred Worker Queue');
\r
35 $info = L10n::t("This page lists the deferred worker jobs. This are jobs that couldn't be executed at the first time.");
\r
37 $condition = ["NOT `done` AND `next_try` < ?", DateTimeFormat::utcNow()];
\r
38 $sub_title = L10n::t('Inspect Worker Queue');
\r
39 $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.');
\r
42 $entries = DBA::select('workerqueue', ['id', 'parameter', 'created', 'priority'], $condition, ['order' => ['priority']]);
\r
45 while ($entry = DBA::fetch($entries)) {
\r
46 // fix GH-5469. ref: src/Core/Worker.php:217
\r
47 $entry['parameter'] = Arrays::recursiveImplode(json_decode($entry['parameter'], true), ': ');
\r
48 $entry['created'] = DateTimeFormat::local($entry['created']);
\r
51 DBA::close($entries);
\r
53 $t = Renderer::getMarkupTemplate('admin/queue.tpl');
\r
54 return Renderer::replaceMacros($t, [
\r
55 '$title' => L10n::t('Administration'),
\r
56 '$page' => $sub_title,
\r
57 '$count' => count($r),
\r
58 '$id_header' => L10n::t('ID'),
\r
59 '$param_header' => L10n::t('Job Parameters'),
\r
60 '$created_header' => L10n::t('Created'),
\r
61 '$prio_header' => L10n::t('Priority'),
\r