Add reset in progress state for sending queue tasks

[MAILPOET-3608]
This commit is contained in:
Jan Lysý
2021-05-19 10:46:51 +02:00
committed by Veljko V
parent 6c54c5900c
commit 55b4051e3f

View File

@@ -97,7 +97,14 @@ class SendingQueue {
$task = $queue->task(); $task = $queue->task();
if (!$task instanceof ScheduledTask) continue; if (!$task instanceof ScheduledTask) continue;
if ($this->isInProgress($task)) continue;
if ($this->isInProgress($task)) {
if ($this->isTimeout($task)) {
$this->stopProgress($task);
} else {
continue;
}
}
$this->startProgress($task); $this->startProgress($task);
@@ -430,8 +437,20 @@ class SendingQueue {
$task->save(); $task->save();
} }
public function getExecutionLimit(): int { private function isTimeout(ScheduledTask $task): bool {
// Convert seconds to minutes $currentTime = Carbon::createFromTimestamp($this->wp->currentTime('timestamp'));
return (int)round($this->cronHelper->getDaemonExecutionLimit() * 2 / 60); $updated = strtotime((string)$task->updatedAt);
if ($updated !== false) {
$updatedAt = Carbon::createFromTimestamp($updated);
}
if (isset($updatedAt) && $updatedAt->diffInSeconds($currentTime, false) > $this->getExecutionLimit()) {
return true;
}
return false;
}
private function getExecutionLimit(): int {
return $this->cronHelper->getDaemonExecutionLimit() * 3;
} }
} }