152 lines
5.2 KiB
PHP
152 lines
5.2 KiB
PHP
|
|
<?php
|
|||
|
|
require_once($_SERVER['DOCUMENT_ROOT'] . "/config.php");
|
|||
|
|
|
|||
|
|
if ($type = $_POST['type'])
|
|||
|
|
{
|
|||
|
|
function getParsers($parser_name = [])
|
|||
|
|
{
|
|||
|
|
$items = array();
|
|||
|
|
|
|||
|
|
foreach ($parser_name as $name)
|
|||
|
|
{
|
|||
|
|
$sql = "SELECT
|
|||
|
|
dps.*
|
|||
|
|
FROM
|
|||
|
|
domclick_parser_stats dps
|
|||
|
|
JOIN
|
|||
|
|
(
|
|||
|
|
SELECT
|
|||
|
|
id
|
|||
|
|
FROM domclick_parser_stats
|
|||
|
|
WHERE
|
|||
|
|
`state` = 'Старт'
|
|||
|
|
AND `parser_name` = '{$name}'
|
|||
|
|
ORDER BY `id`
|
|||
|
|
DESC LIMIT 1
|
|||
|
|
) sub
|
|||
|
|
WHERE
|
|||
|
|
dps.id >= sub.id
|
|||
|
|
AND dps.parser_name = '{$name}'
|
|||
|
|
";
|
|||
|
|
|
|||
|
|
$rez = mysql_query($sql);
|
|||
|
|
|
|||
|
|
if (mysql_num_rows($rez) > 0) {
|
|||
|
|
while ($dbObject = mysql_fetch_assoc($rez)) {
|
|||
|
|
$items[$dbObject['parser_name']][] = $dbObject;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return $items;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$items = getParsers([$_POST['type']]);
|
|||
|
|
?>
|
|||
|
|
|
|||
|
|
<?php foreach ($items as $key => $item) {
|
|||
|
|
$last_record = $item[count($item) - 1];
|
|||
|
|
|
|||
|
|
$status = 'Завершено';
|
|||
|
|
if ($last_record && !in_array($last_record['state'], ['Завершено с ошибкой', 'Завершено успешно'])) {
|
|||
|
|
$status = 'В процессе';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($last_record['state'] == 'Завершено с ошибкой') {
|
|||
|
|
$status = 'Завершено с ошибкой';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!$last_record) {
|
|||
|
|
$status = 'Парсер не был запущен';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$name = 'Другие';
|
|||
|
|
|
|||
|
|
if ($key == 'moscow') {
|
|||
|
|
$name = 'Москва';
|
|||
|
|
}
|
|||
|
|
else if ($key == 'spb') {
|
|||
|
|
$name = 'Санкт-Петербург';
|
|||
|
|
}
|
|||
|
|
?>
|
|||
|
|
<div style="position: relative;">
|
|||
|
|
<button
|
|||
|
|
style="
|
|||
|
|
position: absolute;
|
|||
|
|
right: 36px;
|
|||
|
|
top: 15px;
|
|||
|
|
border: none;
|
|||
|
|
background: #04AA6D;
|
|||
|
|
font-weight: bold;
|
|||
|
|
cursor: pointer;
|
|||
|
|
color: white;
|
|||
|
|
padding: 10px 20px;
|
|||
|
|
border-radius: 4px;"
|
|||
|
|
id="parser-<?= $key ?>" class="parser" data-type="<?= $key ?>"
|
|||
|
|
>
|
|||
|
|
Обновить Таблицу
|
|||
|
|
</button>
|
|||
|
|
<div>
|
|||
|
|
|
|||
|
|
|
|||
|
|
<div id="domclick-parser">
|
|||
|
|
<h2><?= $name ?> - <?= $status ?></h2>
|
|||
|
|
<table>
|
|||
|
|
<thead>
|
|||
|
|
<tr>
|
|||
|
|
<th>Действие</th>
|
|||
|
|
<th>Количество Комплексов</th>
|
|||
|
|
<th>Количество Объектов</th>
|
|||
|
|
<th>Дата</th>
|
|||
|
|
|
|||
|
|
</tr>
|
|||
|
|
</thead>
|
|||
|
|
<tbody>
|
|||
|
|
<?php
|
|||
|
|
|
|||
|
|
$colors = [
|
|||
|
|
'Старт' => '#247d00',
|
|||
|
|
'Создано' => '#2226f0',
|
|||
|
|
'Обновлено' => '#2226f0',
|
|||
|
|
'Удалено' => '#f02222',
|
|||
|
|
'Завершено с ошибкой' => '#f02222',
|
|||
|
|
'Завершено успешно' => '#247d00'
|
|||
|
|
];
|
|||
|
|
|
|||
|
|
foreach ($item as $record) { ?>
|
|||
|
|
<tr>
|
|||
|
|
<td style="color: <?= $colors[$record['state']] ?>"><?= $record['state']?></td>
|
|||
|
|
<td ><?= $record['complex_count'] > 0 ? $record['complex_count'] : '-' ?></td>
|
|||
|
|
<td ><?= $record['object_count'] > 0 ? $record['object_count'] : '-' ?></td>
|
|||
|
|
<td ><?= $record['updated_at']?></td>
|
|||
|
|
</tr>
|
|||
|
|
|
|||
|
|
<?php } ?>
|
|||
|
|
<!-- <tr>
|
|||
|
|
<td>Старт</td>
|
|||
|
|
<td>-</td>
|
|||
|
|
<td>-</td>
|
|||
|
|
<td>31.03.2024 16:25</td>
|
|||
|
|
</tr>
|
|||
|
|
<tr>
|
|||
|
|
<td>Обновлено</td>
|
|||
|
|
<td>10</td>
|
|||
|
|
<td>20</td>
|
|||
|
|
<td>31.03.2024 16:25</td>
|
|||
|
|
</tr>
|
|||
|
|
<tr>
|
|||
|
|
<td>Удалено</td>
|
|||
|
|
<td>2</td>
|
|||
|
|
<td>0</td>
|
|||
|
|
<td>30.03.2024 16:25</td>
|
|||
|
|
</tr> -->
|
|||
|
|
</tbody>
|
|||
|
|
</table>
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
<?php
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
?>
|