Adjusted implementation to a better one (thanks to Michael Vogel)

This commit is contained in:
Unknown 2018-08-07 10:18:59 +02:00
parent 480d573fc5
commit 5c254ee401

View file

@ -746,25 +746,19 @@ function admin_page_federation(App $a)
function admin_page_queue(App $a) function admin_page_queue(App $a)
{ {
// get content from the queue table // get content from the queue table
/* $entries = DBA::p("SELECT `contact`.`name`, `contact`.`nurl`,
//todo: convert q() to DBA::Select() `queue`.`id`, `queue`.`network`, `queue`.`created`, `queue`.`last`
$statement = DBA::Select('`queue` AS `q`, `contact` AS `c`', FROM `queue` INNER JOIN `contact` ON `contact`.`id` = `queue`.`cid`
[ '`c`.`name`', '`c`.`nurl`', '`q`.`id`', '`q`.`network`', "CONVERT_TZ(`q`.`created`, 'UTC' " . Config::get('system', 'default_timezone') . ') as created', "CONVERT_TZ(`q`.`last`, 'UTC', " . Config::get('system', 'default_timezone') . "') as last" ], ORDER BY `queue`.`cid`, `queue`.`created`");
'`c`.`id`' => '`q`.`cid`',
['order'=> ['`q`.`cid`, `q`.`created`']]
);
$r = DBA::toArray($statement);
*/
$r = q("SELECT `c`.`name`, `c`.`nurl`, `q`.`id`, `q`.`network`, `q`.`created`, `q`.`last`
FROM `queue` AS `q`, `contact` AS `c`
WHERE `c`.`id` = `q`.`cid`
ORDER BY `q`.`cid`, `q`.`created`;");
foreach ($r as $key => $rr) { $r = [];
$r[$key]['created'] = DateTimeFormat::local($rr['created']); while ($entry = DBA::fetch($entries)) {
$r[$key]['last'] = DateTimeFormat::local($rr['last']); $entry['created'] = DateTimeFormat::local($entry['created']);
$entry['last'] = DateTimeFormat::local($entry['last']);
$r[] = $entry;
} }
DBA::close($entries);
$t = get_markup_template('admin/queue.tpl'); $t = get_markup_template('admin/queue.tpl');
return replace_macros($t, [ return replace_macros($t, [
'$title' => L10n::t('Administration'), '$title' => L10n::t('Administration'),
@ -795,13 +789,15 @@ function admin_page_queue(App $a)
function admin_page_workerqueue(App $a) function admin_page_workerqueue(App $a)
{ {
// get jobs from the workerqueue table // get jobs from the workerqueue table
$statement = DBA::select('workerqueue', ['id', 'parameter', 'created', 'priority'], ['done' => 0], ['order'=> ['priority']]); $entries = DBA::select('workerqueue', ['id', 'parameter', 'created', 'priority'], ['done' => 0], ['order'=> ['priority']]);
$r = DBA::toArray($statement); $r = DBA::toArray($statement);
foreach ($r as $key => $rr) { $r = [];
while ($entry = DBA::fetch($entries)) {
// fix GH-5469. ref: src/Core/Worker.php:217 // fix GH-5469. ref: src/Core/Worker.php:217
$r[$key]['parameter'] = Arrays::recursiveImplode(json_decode($rr['parameter'], true), ': '); $entry['parameter'] = Arrays::recursiveImplode(json_decode($entry['parameter'], true), ': ');
$r[$key]['created'] = DateTimeFormat::local($rr['created']); $entry['created'] = DateTimeFormat::local($entry['created']);
$r[] = $entry;
} }
$t = get_markup_template('admin/workerqueue.tpl'); $t = get_markup_template('admin/workerqueue.tpl');