Add engagement score to the homepage subscribers stats
[MAILPOET-4828]
This commit is contained in:
committed by
Aschepikov
parent
50a377b749
commit
076f79358e
1
mailpoet/assets/js/src/global.d.ts
vendored
1
mailpoet/assets/js/src/global.d.ts
vendored
@ -203,6 +203,7 @@ interface Window {
|
||||
name: string;
|
||||
id: number;
|
||||
type: string;
|
||||
averageEngagementScore: number;
|
||||
}[];
|
||||
};
|
||||
wooCustomersCount: number;
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { MailPoet } from 'mailpoet';
|
||||
import { useSelect } from '@wordpress/data';
|
||||
import { storeName } from 'homepage/store/store';
|
||||
import { ListingsEngagementScore } from 'subscribers/listings_engagement_score';
|
||||
import { ContentSection } from './content-section';
|
||||
|
||||
export function SubscribersStats(): JSX.Element {
|
||||
@ -33,6 +34,7 @@ export function SubscribersStats(): JSX.Element {
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{MailPoet.I18n.t('listName')}</th>
|
||||
<th>{MailPoet.I18n.t('listScore')}</th>
|
||||
<th>{MailPoet.I18n.t('subscribedSubscribers')}</th>
|
||||
<th>{MailPoet.I18n.t('unsubscribedSubscribers')}</th>
|
||||
</tr>
|
||||
@ -47,6 +49,14 @@ export function SubscribersStats(): JSX.Element {
|
||||
{list.name}
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
<div className="mailpoet-listing-stats">
|
||||
<ListingsEngagementScore
|
||||
id={list.id}
|
||||
engagementScore={list.averageEngagementScore}
|
||||
/>
|
||||
</div>
|
||||
</td>
|
||||
<td>{list.subscribed}</td>
|
||||
<td>{list.unsubscribed}</td>
|
||||
</tr>
|
||||
|
@ -21,6 +21,7 @@ export type ListSubscribersCountChange = {
|
||||
name: string;
|
||||
id: number;
|
||||
type: string;
|
||||
averageEngagementScore: number;
|
||||
};
|
||||
|
||||
export type TaskListTasksStatus = {
|
||||
|
@ -402,7 +402,7 @@ class SubscribersRepository extends Repository {
|
||||
|
||||
public function getListLevelCountsOfSubscribedAfter(\DateTimeInterface $date): array {
|
||||
$data = $this->entityManager->createQueryBuilder()
|
||||
->select('seg.id, seg.name, seg.type, COUNT(ss.id) as count')
|
||||
->select('seg.id, seg.name, seg.type, seg.averageEngagementScore, COUNT(ss.id) as count')
|
||||
->from(SubscriberSegmentEntity::class, 'ss')
|
||||
->join('ss.subscriber', 's')
|
||||
->join('ss.segment', 'seg')
|
||||
@ -422,7 +422,7 @@ class SubscribersRepository extends Repository {
|
||||
|
||||
public function getListLevelCountsOfUnsubscribedAfter(\DateTimeInterface $date): array {
|
||||
return $this->entityManager->createQueryBuilder()
|
||||
->select('seg.id, seg.name, seg.type, COUNT(ss.id) as count')
|
||||
->select('seg.id, seg.name, seg.type, seg.averageEngagementScore, COUNT(ss.id) as count')
|
||||
->from(SubscriberSegmentEntity::class, 'ss')
|
||||
->join('ss.subscriber', 's')
|
||||
->join('ss.segment', 'seg')
|
||||
|
@ -211,6 +211,7 @@ class HomepageDataControllerTest extends \MailPoetTest {
|
||||
$thirtyOneDaysAgo = Carbon::now()->subDays(31);
|
||||
$twentyNineDaysAgo = Carbon::now()->subDays(29);
|
||||
$segment = (new Segment())->withName('Segment')->create();
|
||||
$segment->setAverageEngagementScore(0.5);
|
||||
// Subscribed 29 days ago - only this one counts as subscribed on list level
|
||||
$newSubscribed = (new Subscriber())
|
||||
->withStatus(SubscriberEntity::STATUS_SUBSCRIBED)
|
||||
@ -243,6 +244,7 @@ class HomepageDataControllerTest extends \MailPoetTest {
|
||||
expect($subscribersStats['lists'][0]['name'])->equals($segment->getName());
|
||||
expect($subscribersStats['lists'][0]['subscribed'])->equals(1);
|
||||
expect($subscribersStats['lists'][0]['unsubscribed'])->equals(0);
|
||||
expect($subscribersStats['lists'][0]['averageEngagementScore'])->equals(0.5);
|
||||
}
|
||||
|
||||
public function testItFetchesCorrectListLevelUnsubscribedStats(): void {
|
||||
|
@ -71,5 +71,19 @@
|
||||
'unsubscribedSubscribers': _x('unsubscribed', 'Label for a number of subscribers who unsubscribed from email delivery'),
|
||||
'subscribedSubscribers': _x('subscribed', 'Label for a number of subscribers who subscribed to email delivery'),
|
||||
'listName': __('List name'),
|
||||
'listScore': __('List score'),
|
||||
'unknownBadgeName': __('Unknown'),
|
||||
'unknownBadgeTooltip': __('Not enough data.'),
|
||||
'tooltipUnknown': __('Fewer than 3 emails sent'),
|
||||
'excellentBadgeName': __('Excellent'),
|
||||
'excellentBadgeTooltip': __('Congrats!'),
|
||||
'tooltipExcellent': __('50% or more'),
|
||||
'goodBadgeName': __('Good'),
|
||||
'goodBadgeTooltip': __('Good stuff.'),
|
||||
'tooltipGood': __('between 20 and 50%'),
|
||||
'averageBadgeName': __('Low'),
|
||||
'averageBadgeTooltip': __('Something to improve.'),
|
||||
'tooltipAverage': __('20% or fewer'),
|
||||
'engagementScoreDescription': __('Average percent of emails subscribers read in the last year'),
|
||||
}) %>
|
||||
<% endblock %>
|
||||
|
Reference in New Issue
Block a user