Get rid of previous data for each email as it is not necessary

[MAILPOET-5433]
This commit is contained in:
David Remer
2023-06-27 09:20:31 +03:00
committed by Aschepikov
parent 5aaa7b2361
commit 8f14dee501
4 changed files with 36 additions and 52 deletions

View File

@ -71,12 +71,12 @@ class OverviewStatisticsController {
$newsletter = $this->newslettersRepository->findOneById($newsletterId);
$data['emails'][$newsletterId]['id'] = $newsletterId;
$data['emails'][$newsletterId]['name'] = $newsletter ? $newsletter->getSubject() : '';
$data['emails'][$newsletterId]['sent']['current'] = $statistic->getTotalSentCount();
$data['emails'][$newsletterId]['opened']['current'] = $statistic->getOpenCount();
$data['emails'][$newsletterId]['clicked']['current'] = $statistic->getClickCount();
$data['emails'][$newsletterId]['unsubscribed']['current'] = $statistic->getUnsubscribeCount();
$data['emails'][$newsletterId]['orders']['current'] = $statistic->getWooCommerceRevenue() ? $statistic->getWooCommerceRevenue()->getOrdersCount() : 0;
$data['emails'][$newsletterId]['revenue']['current'] = $statistic->getWooCommerceRevenue() ? $statistic->getWooCommerceRevenue()->getValue() : 0;
$data['emails'][$newsletterId]['sent'] = $statistic->getTotalSentCount();
$data['emails'][$newsletterId]['opened'] = $statistic->getOpenCount();
$data['emails'][$newsletterId]['clicked'] = $statistic->getClickCount();
$data['emails'][$newsletterId]['unsubscribed'] = $statistic->getUnsubscribeCount();
$data['emails'][$newsletterId]['orders'] = $statistic->getWooCommerceRevenue() ? $statistic->getWooCommerceRevenue()->getOrdersCount() : 0;
$data['emails'][$newsletterId]['revenue'] = $statistic->getWooCommerceRevenue() ? $statistic->getWooCommerceRevenue()->getValue() : 0;
$data['emails'][$newsletterId]['previewUrl'] = $newsletter ? $this->newsletterUrl->getViewInBrowserUrl($newsletter) : '';
$data['emails'][$newsletterId]['order'] = count($data['emails']);
}
@ -95,12 +95,6 @@ class OverviewStatisticsController {
$data['unsubscribed']['previous'] += $statistic->getUnsubscribeCount();
$data['orders']['previous'] += $statistic->getWooCommerceRevenue() ? $statistic->getWooCommerceRevenue()->getOrdersCount() : 0;
$data['revenue']['previous'] += $statistic->getWooCommerceRevenue() ? $statistic->getWooCommerceRevenue()->getValue() : 0;
$data['emails'][$newsletterId]['sent']['previous'] = $statistic->getTotalSentCount();
$data['emails'][$newsletterId]['opened']['previous'] = $statistic->getOpenCount();
$data['emails'][$newsletterId]['clicked']['previous'] = $statistic->getClickCount();
$data['emails'][$newsletterId]['unsubscribed']['previous'] = $statistic->getUnsubscribeCount();
$data['emails'][$newsletterId]['orders']['previous'] = $statistic->getWooCommerceRevenue() ? $statistic->getWooCommerceRevenue()->getOrdersCount() : 0;
$data['emails'][$newsletterId]['revenue']['previous'] = $statistic->getWooCommerceRevenue() ? $statistic->getWooCommerceRevenue()->getValue() : 0;
}
usort($data['emails'], function ($a, $b) {