Get rid of previous data for each email as it is not necessary
[MAILPOET-5433]
This commit is contained in:
@ -56,10 +56,7 @@ export function transformEmailsToRows(emails: EmailStats[]) {
|
||||
|
||||
return emails.map((email) => {
|
||||
// Shows the percentage of clicked emails compared to the number of sent emails
|
||||
const clickedPercentage = calculatePercentage(
|
||||
email.clicked.current,
|
||||
email.sent.current,
|
||||
);
|
||||
const clickedPercentage = calculatePercentage(email.clicked, email.sent);
|
||||
const clickedBadge = percentageBadgeCalculation(clickedPercentage);
|
||||
|
||||
return [
|
||||
@ -82,56 +79,49 @@ export function transformEmailsToRows(emails: EmailStats[]) {
|
||||
<a
|
||||
href={`?page=mailpoet-newsletters#/sending-status/${email.id}`}
|
||||
>
|
||||
{`${email.sent.current}`}
|
||||
{`${email.sent}`}
|
||||
</a>
|
||||
</Tooltip>
|
||||
}
|
||||
subValue={
|
||||
// Shows the percentage of sent emails compared to the previous email
|
||||
percentageFormatter.format(
|
||||
calculatePercentage(
|
||||
email.sent.current,
|
||||
email.sent.previous,
|
||||
true,
|
||||
) / 100,
|
||||
calculatePercentage(email.sent, email.sent, true) / 100,
|
||||
)
|
||||
}
|
||||
/>
|
||||
),
|
||||
value: email.sent.current,
|
||||
value: email.sent,
|
||||
},
|
||||
{
|
||||
display: (
|
||||
<Cell
|
||||
value={email.opened.current}
|
||||
value={email.opened}
|
||||
subValue={
|
||||
// Shows the percentage of opened emails compared to the number of sent emails
|
||||
percentageFormatter.format(
|
||||
calculatePercentage(email.opened.current, email.sent.current) /
|
||||
100,
|
||||
calculatePercentage(email.opened, email.sent) / 100,
|
||||
)
|
||||
}
|
||||
/>
|
||||
),
|
||||
value: email.opened.current,
|
||||
value: email.opened,
|
||||
},
|
||||
{
|
||||
display: (
|
||||
<Cell
|
||||
value={email.clicked.current}
|
||||
value={email.clicked}
|
||||
className={
|
||||
email.sent.current > 0
|
||||
email.sent > 0
|
||||
? 'mailpoet-automation-analytics-email-clicked'
|
||||
: ''
|
||||
}
|
||||
subValue={percentageFormatter.format(clickedPercentage / 100)}
|
||||
badge={email.sent.current > 0 ? clickedBadge.badge : undefined}
|
||||
badgeType={
|
||||
email.sent.current > 0 ? clickedBadge.badgeType : undefined
|
||||
}
|
||||
badge={email.sent > 0 ? clickedBadge.badge : undefined}
|
||||
badgeType={email.sent > 0 ? clickedBadge.badgeType : undefined}
|
||||
/>
|
||||
),
|
||||
value: email.clicked.current,
|
||||
value: email.clicked,
|
||||
},
|
||||
{
|
||||
display: (
|
||||
@ -145,21 +135,21 @@ export function transformEmailsToRows(emails: EmailStats[]) {
|
||||
openOrders();
|
||||
}}
|
||||
>
|
||||
{`${email.orders.current}`}
|
||||
{`${email.orders}`}
|
||||
</a>
|
||||
</Tooltip>
|
||||
}
|
||||
/>
|
||||
),
|
||||
value: email.orders.current,
|
||||
value: email.orders,
|
||||
},
|
||||
{
|
||||
display: <Cell value={formattedPrice(email.revenue.current)} />,
|
||||
value: email.revenue.current,
|
||||
display: <Cell value={formattedPrice(email.revenue)} />,
|
||||
value: email.revenue,
|
||||
},
|
||||
{
|
||||
display: <Cell value={email.unsubscribed.current} />,
|
||||
value: email.unsubscribed.current,
|
||||
display: <Cell value={email.unsubscribed} />,
|
||||
value: email.unsubscribed,
|
||||
},
|
||||
{
|
||||
display: <Actions id={email.id} previewUrl={email.previewUrl} />,
|
||||
|
@ -9,12 +9,12 @@ export function calculateSummary(rows: EmailStats[]) {
|
||||
}
|
||||
const data = rows.reduce(
|
||||
(acc, row) => {
|
||||
acc.sent += row.sent.current;
|
||||
acc.opened += row.opened.current;
|
||||
acc.clicked += row.clicked.current;
|
||||
acc.orders += row.orders.current;
|
||||
acc.unsubscribed += row.unsubscribed.current;
|
||||
acc.revenue += row.revenue.current;
|
||||
acc.sent += row.sent;
|
||||
acc.opened += row.opened;
|
||||
acc.clicked += row.clicked;
|
||||
acc.orders += row.orders;
|
||||
acc.unsubscribed += row.unsubscribed;
|
||||
acc.revenue += row.revenue;
|
||||
return acc;
|
||||
},
|
||||
{
|
||||
|
@ -18,12 +18,12 @@ export type EmailStats = {
|
||||
order: number;
|
||||
name: string;
|
||||
previewUrl: string;
|
||||
sent: CurrentAndPrevious;
|
||||
opened: CurrentAndPrevious;
|
||||
clicked: CurrentAndPrevious;
|
||||
orders: CurrentAndPrevious;
|
||||
revenue: CurrentAndPrevious;
|
||||
unsubscribed: CurrentAndPrevious;
|
||||
sent: number;
|
||||
opened: number;
|
||||
clicked: number;
|
||||
orders: number;
|
||||
revenue: number;
|
||||
unsubscribed: number;
|
||||
};
|
||||
|
||||
type OverviewSectionData = SectionData & {
|
||||
|
@ -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) {
|
||||
|
Reference in New Issue
Block a user