Add sending queue status to help page

[MAILPOET-1459]
This commit is contained in:
Rostislav Wolny
2018-07-23 10:14:13 +02:00
parent 0d6e2a107a
commit 1252f35a23
7 changed files with 149 additions and 3 deletions

35
lib/Tasks/State.php Normal file
View File

@ -0,0 +1,35 @@
<?php
namespace MailPoet\Tasks;
use MailPoet\Models\ScheduledTask;
class State
{
/**
* @return array
*/
function getCountsPerStatus() {
$stats = [
ScheduledTask::STATUS_COMPLETED => 0,
ScheduledTask::STATUS_PAUSED => 0,
ScheduledTask::STATUS_SCHEDULED => 0,
ScheduledTask::VIRTUAL_STATUS_RUNNING => 0,
];
$counts = ScheduledTask::rawQuery(
"SELECT COUNT(*) as value, status
FROM `" . ScheduledTask::$_table . "`
WHERE deleted_at IS NULL AND `type` = 'sending'
GROUP BY status;"
)->findMany();
foreach($counts as $count) {
if($count->status === null) {
$stats[ScheduledTask::VIRTUAL_STATUS_RUNNING] = (int)$count->value;
continue;
}
$stats[$count->status] = (int)$count->value;
}
return $stats;
}
}