Add getAutomationsInTimespan method to controller

[MAILPOET-5091]
This commit is contained in:
David Remer
2023-06-28 10:52:06 +03:00
committed by Aschepikov
parent 5e4631ec9d
commit 8b81016814
4 changed files with 25 additions and 22 deletions

View File

@ -21,24 +21,24 @@ class OverviewStatisticsController {
/** @var NewsletterUrl */
private $newsletterUrl;
/** @var AutomationEmailController */
private $automationEmailController;
/** @var AutomationTimeSpanController */
private $automationTimeSpanController;
public function __construct(
NewslettersRepository $newslettersRepository,
NewsletterStatisticsRepository $newsletterStatisticsRepository,
NewsletterUrl $newsletterUrl,
AutomationEmailController $automationEmailController
AutomationTimeSpanController $automationTimeSpanController
) {
$this->newslettersRepository = $newslettersRepository;
$this->newsletterStatisticsRepository = $newsletterStatisticsRepository;
$this->newsletterUrl = $newsletterUrl;
$this->automationEmailController = $automationEmailController;
$this->automationTimeSpanController = $automationTimeSpanController;
}
public function getStatisticsForAutomation(Automation $automation, QueryWithCompare $query): array {
$currentEmails = $this->automationEmailController->getAutomationEmailsInTimeSpan($automation, $query->getAfter(), $query->getBefore());
$previousEmails = $this->automationEmailController->getAutomationEmailsInTimeSpan($automation, $query->getCompareWithAfter(), $query->getCompareWithBefore());
$currentEmails = $this->automationTimeSpanController->getAutomationEmailsInTimeSpan($automation, $query->getAfter(), $query->getBefore());
$previousEmails = $this->automationTimeSpanController->getAutomationEmailsInTimeSpan($automation, $query->getCompareWithAfter(), $query->getCompareWithBefore());
$data = [
'sent' => ['current' => 0, 'previous' => 0],
'opened' => ['current' => 0, 'previous' => 0],