Update Carbon usage in lib
[MAILPOET-3232]
This commit is contained in:
committed by
Veljko V
parent
a376057560
commit
e5a671900b
@@ -44,8 +44,8 @@ class Beamer extends SimpleWorker {
|
|||||||
return $date
|
return $date
|
||||||
->next(Carbon::MONDAY)
|
->next(Carbon::MONDAY)
|
||||||
->startOfDay()
|
->startOfDay()
|
||||||
->addDay(rand(0, 6))
|
->addDays(rand(0, 6))
|
||||||
->addHour(rand(0, 23))
|
->addHours(rand(0, 23))
|
||||||
->addMinute(rand(0, 59));
|
->addMinutes(rand(0, 59));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -325,9 +325,9 @@ class SendingQueue {
|
|||||||
$bounceTasks = ScheduledTask::findFutureScheduledByType(Bounce::TASK_TYPE);
|
$bounceTasks = ScheduledTask::findFutureScheduledByType(Bounce::TASK_TYPE);
|
||||||
if (count($bounceTasks)) {
|
if (count($bounceTasks)) {
|
||||||
$bounceTask = reset($bounceTasks);
|
$bounceTask = reset($bounceTasks);
|
||||||
if (Carbon::createFromTimestamp((int)current_time('timestamp'))->addHour(42)->lessThan($bounceTask->scheduledAt)) {
|
if (Carbon::createFromTimestamp((int)current_time('timestamp'))->addHours(42)->lessThan($bounceTask->scheduledAt)) {
|
||||||
$randomOffset = rand(-6 * 60 * 60, 6 * 60 * 60);
|
$randomOffset = rand(-6 * 60 * 60, 6 * 60 * 60);
|
||||||
$bounceTask->scheduledAt = Carbon::createFromTimestamp((int)current_time('timestamp'))->addSecond((36 * 60 * 60) + $randomOffset);
|
$bounceTask->scheduledAt = Carbon::createFromTimestamp((int)current_time('timestamp'))->addSeconds((36 * 60 * 60) + $randomOffset);
|
||||||
$bounceTask->save();
|
$bounceTask->save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -54,7 +54,7 @@ class LogHandler extends AbstractProcessingHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function purgeOldLogs() {
|
private function purgeOldLogs() {
|
||||||
Log::whereLt('created_at', Carbon::create()->subDays(self::DAYS_TO_KEEP_LOGS)->toDateTimeString())
|
Log::whereLt('created_at', Carbon::now()->subDays(self::DAYS_TO_KEEP_LOGS)->toDateTimeString())
|
||||||
->deleteMany();
|
->deleteMany();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -254,6 +254,9 @@ class NewsletterSaveController {
|
|||||||
$schedule = $this->postNotificationScheduler->processPostNotificationSchedule($newsletterModel);
|
$schedule = $this->postNotificationScheduler->processPostNotificationSchedule($newsletterModel);
|
||||||
$nextRunDateString = Scheduler::getNextRunDate($schedule);
|
$nextRunDateString = Scheduler::getNextRunDate($schedule);
|
||||||
$nextRunDate = $nextRunDateString ? Carbon::createFromFormat('Y-m-d H:i:s', $nextRunDateString) : null;
|
$nextRunDate = $nextRunDateString ? Carbon::createFromFormat('Y-m-d H:i:s', $nextRunDateString) : null;
|
||||||
|
if ($nextRunDate === false) {
|
||||||
|
throw InvalidStateException::create()->withMessage('Invalid next run date generated');
|
||||||
|
}
|
||||||
|
|
||||||
// find previously scheduled jobs and reschedule them
|
// find previously scheduled jobs and reschedule them
|
||||||
$scheduledTasks = $this->scheduledTasksRepository->findByNewsletterAndStatus($newsletter, ScheduledTaskEntity::STATUS_SCHEDULED);
|
$scheduledTasks = $this->scheduledTasksRepository->findByNewsletterAndStatus($newsletter, ScheduledTaskEntity::STATUS_SCHEDULED);
|
||||||
|
@@ -238,6 +238,9 @@ class Functions extends AbstractExtension {
|
|||||||
public function installedInLastTwoWeeks() {
|
public function installedInLastTwoWeeks() {
|
||||||
$maxNumberOfWeeks = 2;
|
$maxNumberOfWeeks = 2;
|
||||||
$installedAt = Carbon::createFromFormat('Y-m-d H:i:s', $this->settings->get('installed_at'));
|
$installedAt = Carbon::createFromFormat('Y-m-d H:i:s', $this->settings->get('installed_at'));
|
||||||
|
if ($installedAt === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return $installedAt->diffInWeeks(Carbon::now()) < $maxNumberOfWeeks;
|
return $installedAt->diffInWeeks(Carbon::now()) < $maxNumberOfWeeks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user