diff --git a/mailpoet/lib/AdminPages/Pages/AutomationEditor.php b/mailpoet/lib/AdminPages/Pages/AutomationEditor.php index b12699a590..9f32f0eade 100644 --- a/mailpoet/lib/AdminPages/Pages/AutomationEditor.php +++ b/mailpoet/lib/AdminPages/Pages/AutomationEditor.php @@ -9,6 +9,7 @@ use MailPoet\Automation\Engine\Data\Step; use MailPoet\Automation\Engine\Data\Workflow; use MailPoet\Automation\Engine\Hooks; use MailPoet\Automation\Engine\Registry; +use MailPoet\Automation\Engine\Storage\WorkflowStatisticsStorage; use MailPoet\Automation\Engine\Storage\WorkflowStorage; use MailPoet\Segments\SegmentsRepository; use MailPoet\WP\Functions as WPFunctions; @@ -18,6 +19,9 @@ class AutomationEditor { /** @var WorkflowStorage */ private $workflowStorage; + /** @var WorkflowStatisticsStorage */ + private $statisticsStorage; + /** @var PageRenderer */ private $pageRenderer; @@ -32,12 +36,14 @@ class AutomationEditor { public function __construct( WorkflowStorage $workflowStorage, + WorkflowStatisticsStorage $statisticsStorage, PageRenderer $pageRenderer, Registry $registry, SegmentsRepository $segmentsRepository, WPFunctions $wp ) { $this->workflowStorage = $workflowStorage; + $this->statisticsStorage = $statisticsStorage; $this->pageRenderer = $pageRenderer; $this->registry = $registry; $this->segmentsRepository = $segmentsRepository; @@ -102,6 +108,7 @@ class AutomationEditor { 'status' => $workflow->getStatus(), 'created_at' => $workflow->getCreatedAt()->format(DateTimeImmutable::W3C), 'updated_at' => $workflow->getUpdatedAt()->format(DateTimeImmutable::W3C), + 'stats' => $this->statisticsStorage->getWorkflowStats($workflow->getId())->toArray(), 'activated_at' => $workflow->getActivatedAt() ? $workflow->getActivatedAt()->format(DateTimeImmutable::W3C) : null, 'author' => [ 'id' => $workflow->getAuthor()->ID, diff --git a/mailpoet/lib/Automation/Engine/Endpoints/Workflows/WorkflowsGetEndpoint.php b/mailpoet/lib/Automation/Engine/Endpoints/Workflows/WorkflowsGetEndpoint.php index 43a47a267b..269bae5698 100644 --- a/mailpoet/lib/Automation/Engine/Endpoints/Workflows/WorkflowsGetEndpoint.php +++ b/mailpoet/lib/Automation/Engine/Endpoints/Workflows/WorkflowsGetEndpoint.php @@ -7,6 +7,7 @@ use MailPoet\API\REST\Request; use MailPoet\API\REST\Response; use MailPoet\Automation\Engine\API\Endpoint; use MailPoet\Automation\Engine\Data\Workflow; +use MailPoet\Automation\Engine\Storage\WorkflowStatisticsStorage; use MailPoet\Automation\Engine\Storage\WorkflowStorage; use MailPoet\Validator\Builder; @@ -14,10 +15,15 @@ class WorkflowsGetEndpoint extends Endpoint { /** @var WorkflowStorage */ private $workflowStorage; + /** @var WorkflowStatisticsStorage */ + private $statisticsStorage; + public function __construct( - WorkflowStorage $workflowStorage + WorkflowStorage $workflowStorage, + WorkflowStatisticsStorage $statisticsStorage ) { $this->workflowStorage = $workflowStorage; + $this->statisticsStorage = $statisticsStorage; } public function handle(Request $request): Response { @@ -41,6 +47,7 @@ class WorkflowsGetEndpoint extends Endpoint { 'status' => $workflow->getStatus(), 'created_at' => $workflow->getCreatedAt()->format(DateTimeImmutable::W3C), 'updated_at' => $workflow->getUpdatedAt()->format(DateTimeImmutable::W3C), + 'stats' => $this->statisticsStorage->getWorkflowStats($workflow->getId())->toArray(), 'activated_at' => $workflow->getActivatedAt() ? $workflow->getActivatedAt()->format(DateTimeImmutable::W3C) : null, 'author' => [ 'id' => $workflow->getAuthor()->ID,