Enh: Added queue clear option at Administration - Information

This commit is contained in:
Lucas Bartholemy 2018-08-10 12:10:23 +02:00
parent 04e6e3a9c4
commit 97d4fe5d3c
3 changed files with 26 additions and 4 deletions

View File

@ -8,6 +8,7 @@ HumHub Change Log
- Fix: Disabled Notification E-Mails for installation sample contents
- Fix: No e-mail summary immediately after installation
- Enh: Added queuing for search updates of commments
- Enh: Added queue clear option at Administration - Information
1.3.1 (August 7, 2018)

View File

@ -11,10 +11,12 @@ namespace humhub\modules\admin\controllers;
use humhub\modules\admin\components\Controller;
use humhub\modules\admin\components\DatabaseInfo;
use humhub\modules\admin\libs\HumHubAPI;
use humhub\modules\queue\driver\MySQL;
use humhub\modules\queue\helpers\QueueHelper;
use humhub\modules\queue\interfaces\QueueInfoInterface;
use humhub\modules\search\jobs\RebuildIndex;
use ReflectionClass;
use ReflectionException;
use Yii;
/**
@ -105,6 +107,15 @@ class InformationController extends Controller
$queue = Yii::$app->queue;
$canClearQueue = false;
if ($queue instanceof MySQL) {
$canClearQueue = true;
$queue->clear();
if (Yii::$app->request->isPost && Yii::$app->request->get('clearQueue') == 1) {
$this->view->setStatusMessage('success', Yii::t('AdminModule.information', 'Queue successfully cleared.'));
}
}
$waitingJobs = null;
$delayedJobs = null;
$doneJobs = null;
@ -122,11 +133,10 @@ class InformationController extends Controller
try {
$reflect = new ReflectionClass($queue);
$driverName = $reflect->getShortName();
} catch (\ReflectionException $e) {
} catch (ReflectionException $e) {
Yii::error('Could not determine queue driver: '. $e->getMessage());
}
return $this->render('background-jobs', [
'lastRunHourly' => $lastRunHourly,
'lastRunDaily' => $lastRunDaily,
@ -134,8 +144,8 @@ class InformationController extends Controller
'delayedJobs' => $delayedJobs,
'doneJobs' => $doneJobs,
'reservedJobs' => $reservedJobs,
'driverName' => $driverName
'driverName' => $driverName,
'canClearQueue' => $canClearQueue
]);
}

View File

@ -8,8 +8,11 @@
* @var int|null $delayedJobs
* @var int|null $doneJobs
* @var int|null $reservedJobs
* @var boolean $canClearQueue
*/
use humhub\widgets\Button;
if (empty($lastRunHourly)) {
$lastRunHourly = "<span style='color:red'>" . Yii::t('AdminModule.information', 'Never') . "</span>";
} else {
@ -39,6 +42,13 @@ if (empty($lastRunDaily)) {
<div class="col-md-6">
<div class="panel">
<div class="panel-heading">
<?php if ($canClearQueue): ?>
<?= Button::danger('Clear queue')
->link(['background-jobs', 'clearQueue' => 1])
->options(['data-method' => 'POST'])
->xs()->right();
?>
<?php endif; ?>
<?= Yii::t('AdminModule.information', '<strong>Queue</strong> Status'); ?>
</div>
<div class="panel-body">
@ -61,6 +71,7 @@ if (empty($lastRunDaily)) {
<strong><?= Yii::t('AdminModule.information', 'Done'); ?></strong><br/>
<?= $doneJobs ?><br/>
<br/>
</div>
</div>
</div>