Elgg  Version 5.1
queue.php
Go to the documentation of this file.
1 <?php
3 
4 // show queue database statistics
5 
6 $header = '<tr><th>' . elgg_echo('admin:statistics:queue:name') . '</th>';
7 $header .= '<th>' . elgg_echo('admin:statistics:queue:row_count') . '</th>';
8 $header .= '<th>' . elgg_echo('admin:statistics:queue:oldest') . '</th>';
9 $header .= '<th>' . elgg_echo('admin:statistics:queue:newest') . '</th></tr>';
10 
11 $qb = Select::fromTable('queue');
12 $qb->select('DISTINCT name');
13 
14 $queue_names = _elgg_services()->db->getData($qb);
15 if (empty($queue_names)) {
16  return;
17 }
18 
19 $rows = '';
20 foreach ($queue_names as $queue) {
21  $qb = Select::fromTable('queue');
22  $qb->select('COUNT(*) AS total');
23  $qb->where($qb->compare('name', '=', $queue->name, ELGG_VALUE_STRING, true));
24 
25  $row_count = _elgg_services()->db->getDataRow($qb);
26  $row_count = empty($row_count) ? 0 : (int) $row_count->total;
27 
28  $qb = Select::fromTable('queue');
29  $qb->select('MIN(timestamp) AS min');
30  $qb->where($qb->compare('name', '=', $queue->name, ELGG_VALUE_STRING, true));
31 
32  $oldest = _elgg_services()->db->getDataRow($qb);
33  $oldest = empty($oldest) ? 0 : (int) $oldest->min;
34  $oldest = elgg_view('output/datetime-local', ['value' => $oldest]);
35 
36  $qb = Select::fromTable('queue');
37  $qb->select('MAX(timestamp) AS max');
38  $qb->where($qb->compare('name', '=', $queue->name, ELGG_VALUE_STRING, true));
39 
40  $newest = _elgg_services()->db->getDataRow($qb);
41  $newest = empty($newest) ? 0 : (int) $newest->max;
42  $newest = elgg_view('output/datetime-local', ['value' => $newest]);
43 
44  $rows .= "<tr><td>{$queue->name}</td><td>{$row_count}</td><td>{$oldest}</td><td>{$newest}</td></tr>";
45 }
46 
47 $body = "<table class='elgg-table'><thead>{$header}</thead><tbody>{$rows}</tbody></table>";
48 
49 echo elgg_view_module('info', elgg_echo('admin:statistics:queue'), $body);
elgg_view_module(string $type, string $title, string $body, array $vars=[])
Wrapper function for the module display pattern.
Definition: views.php:940
$header
Definition: queue.php:6
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
$queue_names
Definition: queue.php:14
elgg_view(string $view, array $vars=[], string $viewtype= '')
Return a parsed view.
Definition: views.php:177
if(empty($queue_names)) $rows
Definition: queue.php:19
const ELGG_VALUE_STRING
Definition: constants.php:112
foreach($queue_names as $queue) $body
Definition: queue.php:47
_elgg_services()
Get the global service provider.
Definition: elgglib.php:346
$qb
Definition: queue.php:11