Move task type const from entity to worker
[MAILPOET-4366]
This commit is contained in:
@ -32,6 +32,8 @@ use MailPoetVendor\Carbon\Carbon;
|
||||
class SendingQueue {
|
||||
public $mailerTask;
|
||||
public $newsletterTask;
|
||||
|
||||
const TASK_TYPE = 'sending';
|
||||
const TASK_BATCH_SIZE = 5;
|
||||
const EMAIL_WITH_INVALID_SEGMENT_OPTION = 'mailpoet_email_with_invalid_segment';
|
||||
|
||||
|
@ -22,7 +22,6 @@ class ScheduledTaskEntity {
|
||||
const STATUS_PAUSED = 'paused';
|
||||
const STATUS_INVALID = 'invalid';
|
||||
const VIRTUAL_STATUS_RUNNING = 'running'; // For historical reasons this is stored as null in DB
|
||||
const TYPE_SENDING = 'sending';
|
||||
const PRIORITY_HIGH = 1;
|
||||
const PRIORITY_MEDIUM = 5;
|
||||
const PRIORITY_LOW = 10;
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace MailPoet\Newsletter\Sending;
|
||||
|
||||
use MailPoet\Cron\Workers\SendingQueue\SendingQueue;
|
||||
use MailPoet\Doctrine\Repository;
|
||||
use MailPoet\Entities\NewsletterEntity;
|
||||
use MailPoet\Entities\ScheduledTaskEntity;
|
||||
@ -138,7 +139,7 @@ class ScheduledTasksRepository extends Repository {
|
||||
->orderBy('st.priority', 'ASC')
|
||||
->addOrderBy('st.updatedAt', 'ASC')
|
||||
->setMaxResults($limit)
|
||||
->setParameter('type', ScheduledTaskEntity::TYPE_SENDING)
|
||||
->setParameter('type', SendingQueue::TASK_TYPE)
|
||||
->getQuery()
|
||||
->getResult();
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace MailPoet\Newsletter\Sending;
|
||||
|
||||
use MailPoet\Cron\Workers\SendingQueue\SendingQueue as SendingQueueWorker;
|
||||
use MailPoet\Entities\ScheduledTaskEntity;
|
||||
use MailPoet\Test\DataFactories\ScheduledTask as ScheduledTaskFactory;
|
||||
use MailPoet\Test\DataFactories\SendingQueue;
|
||||
@ -70,19 +71,19 @@ class ScheduledTasksRepositoryTest extends \MailPoetTest {
|
||||
|
||||
public function testItCanGetRunningSendingTasks(): void {
|
||||
// running task
|
||||
$task = $this->scheduledTaskFactory->create(ScheduledTaskEntity::TYPE_SENDING, null, Carbon::now()->subDay());
|
||||
$task = $this->scheduledTaskFactory->create(SendingQueueWorker::TASK_TYPE, null, Carbon::now()->subDay());
|
||||
$this->sendingQueueFactory->create($task);
|
||||
$expectedResult[] = $task;
|
||||
// deleted task
|
||||
$task = $this->scheduledTaskFactory->create(ScheduledTaskEntity::TYPE_SENDING, null, Carbon::now()->subDay(), Carbon::now());
|
||||
$task = $this->scheduledTaskFactory->create(SendingQueueWorker::TASK_TYPE, null, Carbon::now()->subDay(), Carbon::now());
|
||||
$this->sendingQueueFactory->create($task);
|
||||
// without sending queue
|
||||
$this->scheduledTaskFactory->create(ScheduledTaskEntity::TYPE_SENDING, null, Carbon::now()->subDay());
|
||||
$this->scheduledTaskFactory->create(SendingQueueWorker::TASK_TYPE, null, Carbon::now()->subDay());
|
||||
// scheduled in future
|
||||
$task = $this->scheduledTaskFactory->create(ScheduledTaskEntity::TYPE_SENDING, ScheduledTaskEntity::STATUS_COMPLETED, Carbon::now()->addDay());
|
||||
$task = $this->scheduledTaskFactory->create(SendingQueueWorker::TASK_TYPE, ScheduledTaskEntity::STATUS_COMPLETED, Carbon::now()->addDay());
|
||||
$this->sendingQueueFactory->create($task);
|
||||
// wrong status
|
||||
$task = $this->scheduledTaskFactory->create(ScheduledTaskEntity::TYPE_SENDING, ScheduledTaskEntity::STATUS_SCHEDULED, Carbon::now()->subDay());
|
||||
$task = $this->scheduledTaskFactory->create(SendingQueueWorker::TASK_TYPE, ScheduledTaskEntity::STATUS_SCHEDULED, Carbon::now()->subDay());
|
||||
$this->sendingQueueFactory->create($task);
|
||||
|
||||
$tasks = $this->repository->findRunningSendingTasks();
|
||||
|
Reference in New Issue
Block a user