[*] mq правки
This commit is contained in:
1 parent
c4a15eb369
commit
5af1f285d9
4 files changed
+206
-7
No files matched your search
@@ -211,6 +211,7 @@
|
||||
<li><a href="/admin/users.php"><i class="fa fa-home"></i> <span>Список пользователей</span></a></li>
|
||||
<li><a href="/admin/groups.php"><i class="fa fa-home"></i> <span>Список ролей</span></a></li>
|
||||
<li><a href="/admin/cacheInfo.php"><i class="fa fa-home"></i> <span>Кэширование</span></a></li>
|
||||
<li><a href="/admin/threads.php"><i class="fa fa-home"></i> <span>Диспетчер очереди</span></a></li>
|
||||
<li><a href="/admin/phpcmd.php"><i class="fa fa-home"></i> <span>Командная PHP строка</span></a></li>
|
||||
<li><a href="index.html"><i class="fa fa-home"></i> <span>Dashboard</span></a></li>
|
||||
|
||||
|
||||
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
use Core\Models\{User, MQ};
|
||||
|
||||
require_once __DIR__ . '/inc/header.php';
|
||||
$MQ = new MQ();
|
||||
?>
|
||||
<div class="pageheader">
|
||||
<div class="media">
|
||||
<div class="pageicon pull-left">
|
||||
<i class="fa fa-home"></i>
|
||||
</div>
|
||||
<div class="media-body">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href=""><i class="glyphicon glyphicon-home"></i></a></li>
|
||||
<li>Список пользователей</li>
|
||||
</ul>
|
||||
<h4>Список пользователей</h4>
|
||||
</div>
|
||||
</div><!-- media -->
|
||||
</div><!-- pageheader -->
|
||||
|
||||
<div class="contentpanel">
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-6">
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title">Задания в очереди</h4>
|
||||
<p>Задания, ожидающие выполнения и задания, выполнение которых завершилось ошибкой</p>
|
||||
</div><!-- panel-heading -->
|
||||
<div class="panel-body">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Всего</th>
|
||||
<th>Активных</th>
|
||||
<th>Выполняются</th>
|
||||
<th>Выполнены</th>
|
||||
<th>С ошибкой</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><?=$MQ->getCountTasks();?></td>
|
||||
<td><?=$MQ->getCountTasks(['active' => 'Y', 'in_progress' => 'N']);?></td>
|
||||
<td><?=$MQ->getCountTasks(['active' => 'Y', 'in_progress' => 'Y']);?></td>
|
||||
<td><?=$MQ->getCountTasks(['active' => 'N', 'in_progress' => 'N', 'executed' => 'Y']);?></td>
|
||||
<td><?=$MQ->getCountTasks(['active' => 'N', 'in_progress' => 'N', 'executed' => 'Y', 'status' => MQ::STATUS_ERROR]);?></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div><!-- panel -->
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-sm-6">
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title">Завершенные задания</h4>
|
||||
<p>Задания, которые были успешно выполнены</p>
|
||||
</div><!-- panel-heading -->
|
||||
<div class="panel-body">
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Всего</th>
|
||||
<th>Успешных</th>
|
||||
<th>Неудачных</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><?=$MQ->getCountTasksHistory();?></td>
|
||||
<td><?=$MQ->getCountTasksHistory(['status' => MQ::STATUS_OK]);?></td>
|
||||
<td><?=$MQ->getCountTasksHistory(['status' => MQ::STATUS_ERROR]);?></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div><!-- panel -->
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- table -->
|
||||
<div class="row">
|
||||
<div class="col-md-12r">
|
||||
<p class="lead">Задания в очереди</p>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-primary table-hover mb30">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Активен</th>
|
||||
<th>Выполняется</th>
|
||||
<th>Выполнен</th>
|
||||
<th>Время выполнения</th>
|
||||
<th>Попытки</th>
|
||||
<th>Класс</th>
|
||||
<th>Метод</th>
|
||||
<th>Параметры</th>
|
||||
<th>Статус</th>
|
||||
<th>Результат</th>
|
||||
<th>Создан</th>
|
||||
<th>Обновлен</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$arTasks = $MQ->getTasks();
|
||||
foreach($arTasks as $task) {
|
||||
?>
|
||||
<tr>
|
||||
<td><?=$task['id'];?></td>
|
||||
<td><?=$task['active'] === MQ::VALUE_Y ? 'Да' : 'Нет';?></td>
|
||||
<td><?=$task['in_progress'] === MQ::VALUE_Y ? 'Да' : 'Нет';?></td>
|
||||
<td><?=$task['executed'] === MQ::VALUE_Y ? 'Да' : 'Нет';?></td>
|
||||
<td><?=$task['execution_time'];?></td>
|
||||
<td><?=$task['attempts'];?></td>
|
||||
<td><?=$task['class'];?></td>
|
||||
<td><?=$task['method'];?></td>
|
||||
<td><?=$task['params'];?></td>
|
||||
<td><?=$task['status'];?></td>
|
||||
<td><?=$task['response'];?></td>
|
||||
<td><?=$task['date_created'];?></td>
|
||||
<td><?=$task['date_updated'];?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div><!-- table-responsive -->
|
||||
</div>
|
||||
</div>
|
||||
<!-- end table -->
|
||||
</div><!-- contentpanel -->
|
||||
<?php require_once __DIR__ . '/inc/footer.php'; ?>
|
||||
@@ -72,11 +72,12 @@
|
||||
/**
|
||||
* Вспомогательный метод, формирует WHERE из массива
|
||||
*
|
||||
* @param $where
|
||||
* @param $where
|
||||
* @param string $logic
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function createWhere($where, $logic = 'AND'): string
|
||||
public function createWhere($where, $logic = 'AND'): string
|
||||
{
|
||||
if (!is_array($where)) {
|
||||
return $where;
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
/**
|
||||
* Количество задач для обработки
|
||||
*/
|
||||
const EXECUTION_TASKS_LIMIT = 10;
|
||||
const EXECUTION_TASKS_LIMIT = 100;
|
||||
|
||||
/**
|
||||
* @var DB|null $DB Объект базы
|
||||
@@ -211,8 +211,8 @@
|
||||
private function checkDuplicates(?string $class, string $method, string $params): bool
|
||||
{
|
||||
$count = $this->DB->query(
|
||||
'SELECT count(id) as count FROM ' . self::TABLE . ' WHERE executed="' . self::VALUE_N . '" AND class="' . addslashes($class) . '" and method="' . $method
|
||||
. '" and params="' . addslashes($params) . '"'
|
||||
'SELECT count(id) as count FROM ' . self::TABLE . ' WHERE executed="' . self::VALUE_N . '" AND class="' . addslashes($class)
|
||||
. '" and method="' . $method . '" and params="' . addslashes($params) . '"'
|
||||
)[0]['count'];
|
||||
return ($count > 0);
|
||||
}
|
||||
@@ -297,13 +297,13 @@
|
||||
echo $t->getMessage();
|
||||
}
|
||||
|
||||
SystemFunctions::sendTelegram(
|
||||
/*SystemFunctions::sendTelegram(
|
||||
'Выполнено задание с ID ' . $arTask['id'] . PHP_EOL . 'Время выполнения: ' . $endTime . ' cek.' . PHP_EOL . $arTask['class'] . '::'
|
||||
. $arTask['method'] . '()' . PHP_EOL . print_r(
|
||||
$arTask['params'],
|
||||
true
|
||||
)
|
||||
);
|
||||
);*/
|
||||
|
||||
|
||||
return $executeStatus;
|
||||
@@ -336,4 +336,49 @@
|
||||
|
||||
return $taskHistoryId;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Получение списка всех заданий из очереди
|
||||
*
|
||||
* @param string $limit Лимит
|
||||
*
|
||||
* @return mixed|null
|
||||
*/
|
||||
public function getTasks(string $limit = '10'): ?array
|
||||
{
|
||||
return $this->DB->query('SELECT * FROM ' . self::TABLE . ' ORDER BY id DESC LIMIT ' . $limit) ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Получение количества заданий в очереди
|
||||
*
|
||||
* @param array|null $filter Фильтр
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getCountTasks(?array $filter = null): int
|
||||
{
|
||||
$filterString = '';
|
||||
if (!empty($filter)) {
|
||||
$filterString = ' WHERE ' . $this->DB->createWhere($filter);
|
||||
}
|
||||
return (int)$this->DB->query('SELECT count(id) as count FROM ' . self::TABLE . $filterString)[0]['count'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Получение количества заданий в очереди
|
||||
*
|
||||
* @param array|null $filter Фильтр
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getCountTasksHistory(?array $filter = null): int
|
||||
{
|
||||
$filterString = '';
|
||||
if (!empty($filter)) {
|
||||
$filterString = ' WHERE ' . $this->DB->createWhere($filter);
|
||||
}
|
||||
return (int)$this->DB->query('SELECT count(id) as count FROM ' . self::TABLE_HISTORY . $filterString)[0]['count'];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user