diff --git a/lib/Cron/Daemon.php b/lib/Cron/Daemon.php index 76715445eb..33f500698d 100644 --- a/lib/Cron/Daemon.php +++ b/lib/Cron/Daemon.php @@ -44,6 +44,7 @@ class Daemon { private function getWorkers() { yield $this->workers_factory->createMigrationWorker($this->timer); yield $this->workers_factory->createStatsNotificationsWorker($this->timer); + yield $this->workers_factory->createStatsNotificationsWorkerForAutomatedEmails($this->timer); yield $this->workers_factory->createScheduleWorker($this->timer); yield $this->workers_factory->createQueueWorker($this->timer); yield $this->workers_factory->createSendingServiceKeyCheckWorker($this->timer); diff --git a/lib/Cron/Workers/StatsNotifications/AutomatedEmails.php b/lib/Cron/Workers/StatsNotifications/AutomatedEmails.php new file mode 100644 index 0000000000..5cfab51483 --- /dev/null +++ b/lib/Cron/Workers/StatsNotifications/AutomatedEmails.php @@ -0,0 +1,33 @@ +settings = $settings; + } + + function processTaskStrategy(ScheduledTask $task) { + // TODO + } + + static function getNextRunDate() { + $wp = new WPFunctions; + $date = Carbon::createFromTimestamp($wp->currentTime('timestamp')); + return $date->next(Carbon::MONDAY)->midDay(); + } +} diff --git a/lib/Cron/Workers/WorkersFactory.php b/lib/Cron/Workers/WorkersFactory.php index a04967351a..72e013965a 100644 --- a/lib/Cron/Workers/WorkersFactory.php +++ b/lib/Cron/Workers/WorkersFactory.php @@ -3,10 +3,11 @@ namespace MailPoet\Cron\Workers; use MailPoet\Config\Renderer; -use MailPoet\Cron\Workers\StatsNotifications\Scheduler as StatsNotificationScheduler; use MailPoet\Cron\Workers\Scheduler as SchedulerWorker; use MailPoet\Cron\Workers\SendingQueue\SendingQueue as SendingQueueWorker; use MailPoet\Cron\Workers\SendingQueue\Migration as MigrationWorker; +use MailPoet\Cron\Workers\StatsNotifications\AutomatedEmails as StatsNotificationsWorkerForAutomatedEmails; +use MailPoet\Cron\Workers\StatsNotifications\Scheduler as StatsNotificationScheduler; use MailPoet\Cron\Workers\StatsNotifications\Worker as StatsNotificationsWorker; use MailPoet\Cron\Workers\Bounce as BounceWorker; use MailPoet\Cron\Workers\KeyCheck\PremiumKeyCheck as PremiumKeyCheckWorker; @@ -30,7 +31,7 @@ class WorkersFactory { private $sending_error_handler; /** @var StatsNotificationScheduler */ - private $scheduler; + private $statsNotificationsScheduler; /** @var Mailer */ private $mailer; @@ -66,7 +67,7 @@ class WorkersFactory { public function __construct( SendingErrorHandler $sending_error_handler, - StatsNotificationScheduler $scheduler, + StatsNotificationScheduler $statsNotificationsScheduler, Mailer $mailer, Renderer $renderer, SettingsController $settings, @@ -79,7 +80,7 @@ class WorkersFactory { SubscribersFinder $subscribers_finder ) { $this->sending_error_handler = $sending_error_handler; - $this->scheduler = $scheduler; + $this->statsNotificationsScheduler = $statsNotificationsScheduler; $this->mailer = $mailer; $this->renderer = $renderer; $this->settings = $settings; @@ -99,13 +100,19 @@ class WorkersFactory { /** @return SendingQueueWorker */ function createQueueWorker($timer) { - return new SendingQueueWorker($this->sending_error_handler, $this->scheduler, $timer); + return new SendingQueueWorker($this->sending_error_handler, $this->statsNotificationsScheduler, $timer); } + /** @return StatsNotificationsWorker */ function createStatsNotificationsWorker($timer) { return new StatsNotificationsWorker($this->mailer, $this->renderer, $this->settings, $this->features_controller, $this->woocommerce_helper, $timer); } + /** @return StatsNotificationsWorkerForAutomatedEmails */ + function createStatsNotificationsWorkerForAutomatedEmails($timer) { + return new StatsNotificationsWorkerForAutomatedEmails($this->settings, $timer); + } + /** @return SendingServiceKeyCheckWorker */ function createSendingServiceKeyCheckWorker($timer) { return new SendingServiceKeyCheckWorker($timer); diff --git a/tests/integration/Cron/DaemonHttpRunnerTest.php b/tests/integration/Cron/DaemonHttpRunnerTest.php index 52e7de3955..b19495ccc0 100644 --- a/tests/integration/Cron/DaemonHttpRunnerTest.php +++ b/tests/integration/Cron/DaemonHttpRunnerTest.php @@ -257,6 +257,7 @@ class DaemonHttpRunnerTest extends \MailPoetTest { 'createScheduleWorker' => $worker, 'createQueueWorker' => $worker, 'createStatsNotificationsWorker' => $worker, + 'createStatsNotificationsWorkerForAutomatedEmails' => $worker, 'createSendingServiceKeyCheckWorker' => $worker, 'createPremiumKeyCheckWorker' => $worker, 'createBounceWorker' => $worker, diff --git a/tests/integration/Cron/DaemonTest.php b/tests/integration/Cron/DaemonTest.php index beceb12137..70df52a454 100644 --- a/tests/integration/Cron/DaemonTest.php +++ b/tests/integration/Cron/DaemonTest.php @@ -37,6 +37,7 @@ class DaemonTest extends \MailPoetTest { 'createScheduleWorker' => $this->createSimpleWorkerMock(), 'createQueueWorker' => $this->createSimpleWorkerMock(), 'createStatsNotificationsWorker' => $this->createSimpleWorkerMock(), + 'createStatsNotificationsWorkerForAutomatedEmails' => $this->createSimpleWorkerMock(), 'createSendingServiceKeyCheckWorker' => $this->createSimpleWorkerMock(), 'createPremiumKeyCheckWorker' => $this->createSimpleWorkerMock(), 'createBounceWorker' => $this->createSimpleWorkerMock(),