Add condition to WordPress trigger method

[MAILPOET-1571]
This commit is contained in:
Pavel Dohnal
2019-01-22 09:26:50 +01:00
parent b66c724c4a
commit 627088e43d
2 changed files with 6 additions and 2 deletions

View File

@@ -38,7 +38,7 @@ class Worker {
function process() {
$settings = Setting::getValue(self::SETTINGS_KEY);
$this->mailer->sender = $this->mailer->getSenderNameAndAddress($this->constructSenderEmail());
foreach($this->getTasks() as $task) {
foreach(self::getDueTasks() as $task) {
try {
$this->mailer->send($this->constructNewsletter($task), $settings['address']);
} catch(\Exception $e) {
@@ -64,7 +64,7 @@ class Worker {
];
}
private function getTasks() {
public static function getDueTasks() {
$date = new Carbon();
return ScheduledTask::orderByAsc('priority')
->orderByAsc('updated_at')