Fix inconsistency between automation run and run log statuses

[MAILPOET-5568]
This commit is contained in:
Jan Jakes
2023-08-31 14:49:17 +02:00
committed by Aschepikov
parent d7addd8e55
commit d8afb42d89
4 changed files with 7 additions and 8 deletions

View File

@@ -8,10 +8,9 @@ use MailPoet\Automation\Engine\Utils\Json;
use Throwable; use Throwable;
class AutomationRunLog { class AutomationRunLog {
public const STATUS_RUNNING = 'running';
const STATUS_RUNNING = 'running'; public const STATUS_COMPLETE = 'complete';
const STATUS_COMPLETED = 'completed'; public const STATUS_FAILED = 'failed';
const STATUS_FAILED = 'failed';
/** @var int */ /** @var int */
private $id; private $id;
@@ -113,7 +112,7 @@ class AutomationRunLog {
} }
public function markCompletedSuccessfully(): void { public function markCompletedSuccessfully(): void {
$this->status = self::STATUS_COMPLETED; $this->status = self::STATUS_COMPLETE;
$this->completedAt = new DateTimeImmutable(); $this->completedAt = new DateTimeImmutable();
} }

View File

@@ -67,7 +67,7 @@ class StepStatisticController {
public function getFlowStatistics(Automation $automation, Query $query): array { public function getFlowStatistics(Automation $automation, Query $query): array {
$statistics = $this->automationRunLogStorage->getAutomationRunStatisticsForAutomationInTimeFrame( $statistics = $this->automationRunLogStorage->getAutomationRunStatisticsForAutomationInTimeFrame(
$automation->getId(), $automation->getId(),
AutomationRunLog::STATUS_COMPLETED, AutomationRunLog::STATUS_COMPLETE,
$query->getAfter(), $query->getAfter(),
$query->getBefore() $query->getBefore()
); );

View File

@@ -147,7 +147,7 @@ class AutomationRunLogTest extends \MailPoetTest {
$automationRunLogs = $this->getLogsForAction(); $automationRunLogs = $this->getLogsForAction();
expect($automationRunLogs)->count(1); expect($automationRunLogs)->count(1);
$log = $automationRunLogs[0]; $log = $automationRunLogs[0];
expect($log->getStatus())->equals(AutomationRunLog::STATUS_COMPLETED); expect($log->getStatus())->equals(AutomationRunLog::STATUS_COMPLETE);
} }
public function testItStoresAutomationRunAndStepIdsCorrectly() { public function testItStoresAutomationRunAndStepIdsCorrectly() {

View File

@@ -64,7 +64,7 @@ class AutomationRunLogStorageTest extends \MailPoetTest {
'after' => new \DateTimeImmutable('2020-01-01 00:00:00'), 'after' => new \DateTimeImmutable('2020-01-01 00:00:00'),
'before' => new \DateTimeImmutable('2020-01-02 00:00:00'), 'before' => new \DateTimeImmutable('2020-01-02 00:00:00'),
]; ];
$status = AutomationRunLog::STATUS_COMPLETED; $status = AutomationRunLog::STATUS_COMPLETE;
$automationId = 1; $automationId = 1;
$this->storage->truncate(); $this->storage->truncate();