Reschedules past due scheduled queues when reactivating notification

This commit is contained in:
Vlad
2017-08-24 20:57:43 -04:00
committed by pavel-mailpoet
parent 544bf0ddfd
commit c1e542cb5a
4 changed files with 85 additions and 7 deletions

View File

@ -176,6 +176,18 @@ class Scheduler {
return $next_run_date;
}
static function getPreviousRunDate($schedule, $from_timestamp = false) {
$from_timestamp = ($from_timestamp) ? $from_timestamp : current_time('timestamp');
try {
$schedule = \Cron\CronExpression::factory($schedule);
$previous_run_date = $schedule->getPreviousRunDate(Carbon::createFromTimestamp($from_timestamp))
->format('Y-m-d H:i:s');
} catch(\Exception $e) {
$previous_run_date = false;
}
return $previous_run_date;
}
static function getNewsletters($type) {
return Newsletter::getPublished()
->filter('filterType', $type)