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) => {
|
return emails.map((email) => {
|
||||||
// Shows the percentage of clicked emails compared to the number of sent emails
|
// Shows the percentage of clicked emails compared to the number of sent emails
|
||||||
const clickedPercentage = calculatePercentage(
|
const clickedPercentage = calculatePercentage(email.clicked, email.sent);
|
||||||
email.clicked.current,
|
|
||||||
email.sent.current,
|
|
||||||
);
|
|
||||||
const clickedBadge = percentageBadgeCalculation(clickedPercentage);
|
const clickedBadge = percentageBadgeCalculation(clickedPercentage);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
@ -82,56 +79,49 @@ export function transformEmailsToRows(emails: EmailStats[]) {
|
|||||||
<a
|
<a
|
||||||
href={`?page=mailpoet-newsletters#/sending-status/${email.id}`}
|
href={`?page=mailpoet-newsletters#/sending-status/${email.id}`}
|
||||||
>
|
>
|
||||||
{`${email.sent.current}`}
|
{`${email.sent}`}
|
||||||
</a>
|
</a>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
}
|
}
|
||||||
subValue={
|
subValue={
|
||||||
// Shows the percentage of sent emails compared to the previous email
|
// Shows the percentage of sent emails compared to the previous email
|
||||||
percentageFormatter.format(
|
percentageFormatter.format(
|
||||||
calculatePercentage(
|
calculatePercentage(email.sent, email.sent, true) / 100,
|
||||||
email.sent.current,
|
|
||||||
email.sent.previous,
|
|
||||||
true,
|
|
||||||
) / 100,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
value: email.sent.current,
|
value: email.sent,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
display: (
|
display: (
|
||||||
<Cell
|
<Cell
|
||||||
value={email.opened.current}
|
value={email.opened}
|
||||||
subValue={
|
subValue={
|
||||||
// Shows the percentage of opened emails compared to the number of sent emails
|
// Shows the percentage of opened emails compared to the number of sent emails
|
||||||
percentageFormatter.format(
|
percentageFormatter.format(
|
||||||
calculatePercentage(email.opened.current, email.sent.current) /
|
calculatePercentage(email.opened, email.sent) / 100,
|
||||||
100,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
value: email.opened.current,
|
value: email.opened,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
display: (
|
display: (
|
||||||
<Cell
|
<Cell
|
||||||
value={email.clicked.current}
|
value={email.clicked}
|
||||||
className={
|
className={
|
||||||
email.sent.current > 0
|
email.sent > 0
|
||||||
? 'mailpoet-automation-analytics-email-clicked'
|
? 'mailpoet-automation-analytics-email-clicked'
|
||||||
: ''
|
: ''
|
||||||
}
|
}
|
||||||
subValue={percentageFormatter.format(clickedPercentage / 100)}
|
subValue={percentageFormatter.format(clickedPercentage / 100)}
|
||||||
badge={email.sent.current > 0 ? clickedBadge.badge : undefined}
|
badge={email.sent > 0 ? clickedBadge.badge : undefined}
|
||||||
badgeType={
|
badgeType={email.sent > 0 ? clickedBadge.badgeType : undefined}
|
||||||
email.sent.current > 0 ? clickedBadge.badgeType : undefined
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
value: email.clicked.current,
|
value: email.clicked,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
display: (
|
display: (
|
||||||
@ -145,21 +135,21 @@ export function transformEmailsToRows(emails: EmailStats[]) {
|
|||||||
openOrders();
|
openOrders();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{`${email.orders.current}`}
|
{`${email.orders}`}
|
||||||
</a>
|
</a>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
value: email.orders.current,
|
value: email.orders,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
display: <Cell value={formattedPrice(email.revenue.current)} />,
|
display: <Cell value={formattedPrice(email.revenue)} />,
|
||||||
value: email.revenue.current,
|
value: email.revenue,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
display: <Cell value={email.unsubscribed.current} />,
|
display: <Cell value={email.unsubscribed} />,
|
||||||
value: email.unsubscribed.current,
|
value: email.unsubscribed,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
display: <Actions id={email.id} previewUrl={email.previewUrl} />,
|
display: <Actions id={email.id} previewUrl={email.previewUrl} />,
|
||||||
|
@ -9,12 +9,12 @@ export function calculateSummary(rows: EmailStats[]) {
|
|||||||
}
|
}
|
||||||
const data = rows.reduce(
|
const data = rows.reduce(
|
||||||
(acc, row) => {
|
(acc, row) => {
|
||||||
acc.sent += row.sent.current;
|
acc.sent += row.sent;
|
||||||
acc.opened += row.opened.current;
|
acc.opened += row.opened;
|
||||||
acc.clicked += row.clicked.current;
|
acc.clicked += row.clicked;
|
||||||
acc.orders += row.orders.current;
|
acc.orders += row.orders;
|
||||||
acc.unsubscribed += row.unsubscribed.current;
|
acc.unsubscribed += row.unsubscribed;
|
||||||
acc.revenue += row.revenue.current;
|
acc.revenue += row.revenue;
|
||||||
return acc;
|
return acc;
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -18,12 +18,12 @@ export type EmailStats = {
|
|||||||
order: number;
|
order: number;
|
||||||
name: string;
|
name: string;
|
||||||
previewUrl: string;
|
previewUrl: string;
|
||||||
sent: CurrentAndPrevious;
|
sent: number;
|
||||||
opened: CurrentAndPrevious;
|
opened: number;
|
||||||
clicked: CurrentAndPrevious;
|
clicked: number;
|
||||||
orders: CurrentAndPrevious;
|
orders: number;
|
||||||
revenue: CurrentAndPrevious;
|
revenue: number;
|
||||||
unsubscribed: CurrentAndPrevious;
|
unsubscribed: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
type OverviewSectionData = SectionData & {
|
type OverviewSectionData = SectionData & {
|
||||||
|
@ -71,12 +71,12 @@ class OverviewStatisticsController {
|
|||||||
$newsletter = $this->newslettersRepository->findOneById($newsletterId);
|
$newsletter = $this->newslettersRepository->findOneById($newsletterId);
|
||||||
$data['emails'][$newsletterId]['id'] = $newsletterId;
|
$data['emails'][$newsletterId]['id'] = $newsletterId;
|
||||||
$data['emails'][$newsletterId]['name'] = $newsletter ? $newsletter->getSubject() : '';
|
$data['emails'][$newsletterId]['name'] = $newsletter ? $newsletter->getSubject() : '';
|
||||||
$data['emails'][$newsletterId]['sent']['current'] = $statistic->getTotalSentCount();
|
$data['emails'][$newsletterId]['sent'] = $statistic->getTotalSentCount();
|
||||||
$data['emails'][$newsletterId]['opened']['current'] = $statistic->getOpenCount();
|
$data['emails'][$newsletterId]['opened'] = $statistic->getOpenCount();
|
||||||
$data['emails'][$newsletterId]['clicked']['current'] = $statistic->getClickCount();
|
$data['emails'][$newsletterId]['clicked'] = $statistic->getClickCount();
|
||||||
$data['emails'][$newsletterId]['unsubscribed']['current'] = $statistic->getUnsubscribeCount();
|
$data['emails'][$newsletterId]['unsubscribed'] = $statistic->getUnsubscribeCount();
|
||||||
$data['emails'][$newsletterId]['orders']['current'] = $statistic->getWooCommerceRevenue() ? $statistic->getWooCommerceRevenue()->getOrdersCount() : 0;
|
$data['emails'][$newsletterId]['orders'] = $statistic->getWooCommerceRevenue() ? $statistic->getWooCommerceRevenue()->getOrdersCount() : 0;
|
||||||
$data['emails'][$newsletterId]['revenue']['current'] = $statistic->getWooCommerceRevenue() ? $statistic->getWooCommerceRevenue()->getValue() : 0;
|
$data['emails'][$newsletterId]['revenue'] = $statistic->getWooCommerceRevenue() ? $statistic->getWooCommerceRevenue()->getValue() : 0;
|
||||||
$data['emails'][$newsletterId]['previewUrl'] = $newsletter ? $this->newsletterUrl->getViewInBrowserUrl($newsletter) : '';
|
$data['emails'][$newsletterId]['previewUrl'] = $newsletter ? $this->newsletterUrl->getViewInBrowserUrl($newsletter) : '';
|
||||||
$data['emails'][$newsletterId]['order'] = count($data['emails']);
|
$data['emails'][$newsletterId]['order'] = count($data['emails']);
|
||||||
}
|
}
|
||||||
@ -95,12 +95,6 @@ class OverviewStatisticsController {
|
|||||||
$data['unsubscribed']['previous'] += $statistic->getUnsubscribeCount();
|
$data['unsubscribed']['previous'] += $statistic->getUnsubscribeCount();
|
||||||
$data['orders']['previous'] += $statistic->getWooCommerceRevenue() ? $statistic->getWooCommerceRevenue()->getOrdersCount() : 0;
|
$data['orders']['previous'] += $statistic->getWooCommerceRevenue() ? $statistic->getWooCommerceRevenue()->getOrdersCount() : 0;
|
||||||
$data['revenue']['previous'] += $statistic->getWooCommerceRevenue() ? $statistic->getWooCommerceRevenue()->getValue() : 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) {
|
usort($data['emails'], function ($a, $b) {
|
||||||
|
Reference in New Issue
Block a user