]> git.mxchange.org Git - friendica.git/commitdiff
Move admin/queue to src/Module
authorHypolite Petovan <hypolite@mrpetovan.com>
Mon, 22 Apr 2019 21:31:12 +0000 (17:31 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Thu, 2 May 2019 13:52:48 +0000 (09:52 -0400)
- Add Module\Admin\Queue class
- Add route for admin/queue[/deferred]
- Add queue admin aside menu entry
- Remove obsolete templates/admin/queue.tpl from base and frio
- Move templates/admin/workerqueue.tpl to templates/admin/queue.tpl
- Remove admin_page_workerqueue and admin_page_workerqueue_post from mod/admin.php
- Update admin/summary.tpl with new queue admin paths

mod/admin.php
src/App/Router.php
src/Module/Admin/Queue.php [new file with mode: 0644]
src/Module/BaseAdminModule.php
view/templates/admin/queue.tpl
view/templates/admin/summary.tpl
view/templates/admin/workerqueue.tpl [deleted file]
view/theme/frio/templates/admin/queue.tpl
view/theme/frio/templates/admin/summary.tpl
view/theme/frio/templates/admin/workerqueue.tpl [deleted file]

index e77780c086ed45a1331b895497f16371d09e965e..7f2077bead1baf3b96c8d4bca9fc517909fde864 100644 (file)
@@ -228,12 +228,6 @@ function admin_content(App $a)
                        case 'dbsync':
                                $o = admin_page_dbsync($a);
                                break;
-                       case 'deferred':
-                               $o = admin_page_workerqueue($a, true);
-                               break;
-                       case 'workerqueue':
-                               $o = admin_page_workerqueue($a, false);
-                               break;
                        case 'deleteitem':
                                $o = admin_page_deleteitem($a);
                                break;
@@ -311,57 +305,6 @@ function admin_page_deleteitem_post(App $a)
        return; // NOTREACHED
 }
 
-/**
- * @brief Admin Inspect Worker 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.
- *
- * The returned string holds the content of the page.
- *
- * @param App $a
- * @param     $deferred
- * @return string
- * @throws \Friendica\Network\HTTPException\InternalServerErrorException
- */
-function admin_page_workerqueue(App $a, $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/workerqueue.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,
-       ]);
-}
-
 /**
  * @brief Process send data from Admin Site Page
  *
index 1cf19c53d6f707d307afadcc5c33a7aed055dff2..0fbb78b8bc7c217dc733eef75b36e32d32b23b69 100644 (file)
@@ -130,6 +130,8 @@ class Router
                        $collector->addRoute(['GET', 'POST'], '/features'               , Module\Admin\Features::class);
                        $collector->addRoute(['GET']        , '/federation'             , Module\Admin\Federation::class);
 
+                       $collector->addRoute(['GET']        , '/queue[/deferred]'       , Module\Admin\Queue::class);
+
                        $collector->addRoute(['GET', 'POST'], '/themes'                 , Module\Admin\Themes\Index::class);
 
                        $collector->addRoute(['GET', 'POST'], '/tos'                    , Module\Admin\Tos::class);
diff --git a/src/Module/Admin/Queue.php b/src/Module/Admin/Queue.php
new file mode 100644 (file)
index 0000000..7055291
--- /dev/null
@@ -0,0 +1,66 @@
+<?php\r
+\r
+namespace Friendica\Module\Admin;\r
+\r
+use Friendica\Core\L10n;\r
+use Friendica\Core\Renderer;\r
+use Friendica\Database\DBA;\r
+use Friendica\Module\BaseAdminModule;\r
+use Friendica\Util\Arrays;\r
+use Friendica\Util\DateTimeFormat;\r
+\r
+/**\r
+ * @brief Admin Inspect Queue Page\r
+ *\r
+ * Generates a page for the admin to have a look into the current queue of\r
+ * worker jobs. Shown are the parameters for the job and its priority.\r
+ *\r
+ * @return string\r
+ */\r
+class Queue extends BaseAdminModule\r
+{\r
+       public static function content()\r
+       {\r
+               parent::content();\r
+\r
+               $a = self::getApp();\r
+\r
+               // @TODO: Replace with parameter from router\r
+               $deferred = $a->argc > 2 && $a->argv[2] == 'deferred';\r
+\r
+               // get jobs from the workerqueue table\r
+               if ($deferred) {\r
+                       $condition = ["NOT `done` AND `next_try` > ?", DateTimeFormat::utcNow()];\r
+                       $sub_title = L10n::t('Inspect Deferred Worker Queue');\r
+                       $info = L10n::t("This page lists the deferred worker jobs. This are jobs that couldn't be executed at the first time.");\r
+               } else {\r
+                       $condition = ["NOT `done` AND `next_try` < ?", DateTimeFormat::utcNow()];\r
+                       $sub_title = L10n::t('Inspect Worker Queue');\r
+                       $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
+               }\r
+\r
+               $entries = DBA::select('workerqueue', ['id', 'parameter', 'created', 'priority'], $condition, ['order' => ['priority']]);\r
+\r
+               $r = [];\r
+               while ($entry = DBA::fetch($entries)) {\r
+                       // fix GH-5469. ref: src/Core/Worker.php:217\r
+                       $entry['parameter'] = Arrays::recursiveImplode(json_decode($entry['parameter'], true), ': ');\r
+                       $entry['created'] = DateTimeFormat::local($entry['created']);\r
+                       $r[] = $entry;\r
+               }\r
+               DBA::close($entries);\r
+\r
+               $t = Renderer::getMarkupTemplate('admin/queue.tpl');\r
+               return Renderer::replaceMacros($t, [\r
+                       '$title' => L10n::t('Administration'),\r
+                       '$page' => $sub_title,\r
+                       '$count' => count($r),\r
+                       '$id_header' => L10n::t('ID'),\r
+                       '$param_header' => L10n::t('Job Parameters'),\r
+                       '$created_header' => L10n::t('Created'),\r
+                       '$prio_header' => L10n::t('Priority'),\r
+                       '$info' => $info,\r
+                       '$entries' => $r,\r
+               ]);\r
+       }\r
+}\r
index bc84ad8873f279038af943fae654275167f9493d..c31ce8ca06a9d29545ece814887c6a11c2f8e74b 100644 (file)
@@ -59,6 +59,10 @@ abstract class BaseAdminModule extends BaseModule
                                'features'     => ['admin/features'    , L10n::t('Additional features')     , 'features'],\r
                                'tos'          => ['admin/tos'         , L10n::t('Terms of Service')        , 'tos'],\r
                        ]],\r
+                       'database' => [L10n::t('Database'), [\r
+                               'deferred'     => ['admin/queue/deferred', L10n::t('Inspect Deferred Workers'), 'deferred'],\r
+                               'workerqueue'  => ['admin/queue'       , L10n::t('Inspect worker Queue')    , 'workerqueue'],\r
+                       ]],\r
                        'tools' => [L10n::t('Tools'), [\r
                                'contactblock' => ['admin/blocklist/contact', L10n::t('Contact Blocklist')  , 'contactblock'],\r
                                'blocklist'    => ['admin/blocklist/server' , L10n::t('Server Blocklist')   , 'blocklist'],\r
index aaca9b014877d37db584bf1e501da73277eef076..5bab58a5e91937b044dcdfc90747f20b9d3cbfab 100644 (file)
@@ -5,20 +5,16 @@
        <table>
                <tr>
                        <th>{{$id_header}}</th>
-                       <th>{{$to_header}}</th>
-                       <th>{{$url_header}}</th>
-                       <th>{{$network_header}}</th>
+                       <th>{{$param_header}}</th>
                        <th>{{$created_header}}</th>
-                       <th>{{$last_header}}</th>
+                       <th>{{$prio_header}}</th>
                </tr>
                {{foreach $entries as $e}}
                <tr>
                        <td>{{$e.id}}</td>
-                       <td>{{$e.name}}</td>
-                       <td><a href="{{$e.nurl}}">{{$e.nurl}}</a></td>
-                       <td>{{$e.network}}</td>
+                       <td>{{$e.parameter}}</td>
                        <td>{{$e.created}}</td>
-                       <td>{{$e.last}}</td>
+                       <td>{{$e.priority}}</td>
                </tr>
                {{/foreach}}
        </table>
index 7b655a8ecc0d4953d682f67f2d22b8f6cb575fc2..121eb833b9ae1284add8cd50d0cfc6eed9caf1d3 100644 (file)
@@ -11,7 +11,7 @@
 
        <dl>
                <dt>{{$queues.label}}</dt>
-               <dd><a href="{{$baseurl}}/admin/deferred">{{$queues.deferred}}</a> - <a href="{{$baseurl}}/admin/workerqueue">{{$queues.workerq}}</a></dd>
+               <dd><a href="{{$baseurl}}/admin/queue/deferred">{{$queues.deferred}}</a> - <a href="{{$baseurl}}/admin/queue">{{$queues.workerq}}</a></dd>
        </dl>
        <dl>
                <dt>{{$pending.0}}</dt>
diff --git a/view/templates/admin/workerqueue.tpl b/view/templates/admin/workerqueue.tpl
deleted file mode 100644 (file)
index 5bab58a..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-<div id='adminpage'>
-       <h1>{{$title}} - {{$page}} ({{$count}})</h1>
-       
-       <p>{{$info}}</p>
-       <table>
-               <tr>
-                       <th>{{$id_header}}</th>
-                       <th>{{$param_header}}</th>
-                       <th>{{$created_header}}</th>
-                       <th>{{$prio_header}}</th>
-               </tr>
-               {{foreach $entries as $e}}
-               <tr>
-                       <td>{{$e.id}}</td>
-                       <td>{{$e.parameter}}</td>
-                       <td>{{$e.created}}</td>
-                       <td>{{$e.priority}}</td>
-               </tr>
-               {{/foreach}}
-       </table>
-</div>
index dde38639991636fe3fbcdf427e8f0e4551260bc9..ab076a0f73a78102dd8c5511136195e0b09cdf3b 100644 (file)
@@ -5,20 +5,16 @@
        <table class="table">
                <tr>
                        <th>{{$id_header}}</th>
-                       <th>{{$to_header}}</th>
-                       <th>{{$url_header}}</th>
-                       <th>{{$network_header}}</th>
+                       <th>{{$param_header}}</th>
                        <th>{{$created_header}}</th>
-                       <th>{{$last_header}}</th>
+                       <th>{{$prio_header}}</th>
                </tr>
                {{foreach $entries as $e}}
                <tr>
                        <td>{{$e.id}}</td>
-                       <td>{{$e.name}}</td>
-                       <td><a href="{{$e.nurl}}">{{$e.nurl}}</a></td>
-                       <td>{{$e.network}}</td>
+                       <td>{{$e.parameter}}</td>
                        <td>{{$e.created}}</td>
-                       <td>{{$e.last}}</td>
+                       <td>{{$e.priority}}</td>
                </tr>
                {{/foreach}}
        </table>
index 9dbd3f7e6b3a25662279885237897a3949510e35..0fd599b051b0d5be389bde23a928b344c9a947e3 100644 (file)
@@ -14,7 +14,7 @@
                {{* The work queues short statistic. *}}
                <div id="admin-summary-queues" class="col-lg-12 col-md-12 col-sm-12 col-xs-12 admin-summary">
                        <div class="col-lg-4 col-md-4 col-sm-4 col-xs-12 admin-summary-label-name text-muted">{{$queues.label}}</div>
-                       <div class="col-lg-8 col-md-8 col-sm-8 col-xs-12 admin-summary-entry"><a href="{{$baseurl}}/admin/deferred">{{$queues.deferred}}</a> - <a href="{{$baseurl}}/admin/workerqueue">{{$queues.workerq}}</a></div>
+                       <div class="col-lg-8 col-md-8 col-sm-8 col-xs-12 admin-summary-entry"><a href="{{$baseurl}}/admin/queue/deferred">{{$queues.deferred}}</a> - <a href="{{$baseurl}}/admin/queue">{{$queues.workerq}}</a></div>
                </div>
 
                {{* Number of pending registrations. *}}
diff --git a/view/theme/frio/templates/admin/workerqueue.tpl b/view/theme/frio/templates/admin/workerqueue.tpl
deleted file mode 100644 (file)
index ab076a0..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-<div id="adminpage">
-       <h1>{{$title}} - {{$page}} ({{$count}})</h1>
-       
-       <p>{{$info}}</p>
-       <table class="table">
-               <tr>
-                       <th>{{$id_header}}</th>
-                       <th>{{$param_header}}</th>
-                       <th>{{$created_header}}</th>
-                       <th>{{$prio_header}}</th>
-               </tr>
-               {{foreach $entries as $e}}
-               <tr>
-                       <td>{{$e.id}}</td>
-                       <td>{{$e.parameter}}</td>
-                       <td>{{$e.created}}</td>
-                       <td>{{$e.priority}}</td>
-               </tr>
-               {{/foreach}}
-       </table>
-</div>