Round score to 1 decimal instead of 0
[MAILPOET-3525]
This commit is contained in:
@ -7,12 +7,24 @@ interface Props {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const ListingsEngagementScore: React.FunctionComponent<Props> = ({ subscriber }) => (
|
export const ListingsEngagementScore: React.FunctionComponent<Props> = ({ subscriber }) => (
|
||||||
<div className="mailpoet-listing-stats-opened-clicked">
|
<div className="mailpoet-listing-stats">
|
||||||
{subscriber.engagement_score != null && (
|
<div className="mailpoet-listing-stats-opened-clicked">
|
||||||
<div className="mailpoet-listing-stats-percentages">
|
{subscriber.engagement_score != null && (
|
||||||
{subscriber.engagement_score}
|
<div className="mailpoet-listing-stats-percentages">
|
||||||
%
|
{
|
||||||
</div>
|
subscriber
|
||||||
)}
|
.engagement_score
|
||||||
|
.toLocaleString(
|
||||||
|
undefined,
|
||||||
|
{
|
||||||
|
minimumFractionDigits: 1,
|
||||||
|
maximumFractionDigits: 1,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
%
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -216,7 +216,7 @@ class Migrator {
|
|||||||
'count_confirmations int(11) unsigned NOT NULL DEFAULT 0,',
|
'count_confirmations int(11) unsigned NOT NULL DEFAULT 0,',
|
||||||
'unsubscribe_token char(15) NULL,',
|
'unsubscribe_token char(15) NULL,',
|
||||||
'link_token char(32) NULL,',
|
'link_token char(32) NULL,',
|
||||||
'engagement_score tinyint unsigned NULL,',
|
'engagement_score FLOAT unsigned NULL,',
|
||||||
'engagement_score_updated_at timestamp NULL,',
|
'engagement_score_updated_at timestamp NULL,',
|
||||||
'PRIMARY KEY (id),',
|
'PRIMARY KEY (id),',
|
||||||
'UNIQUE KEY email (email),',
|
'UNIQUE KEY email (email),',
|
||||||
|
@ -39,6 +39,7 @@ class SubscribersEngagementScore extends SimpleWorker {
|
|||||||
if ($subscribers) {
|
if ($subscribers) {
|
||||||
$this->schedule();
|
$this->schedule();
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getNextRunDate() {
|
public function getNextRunDate() {
|
||||||
|
@ -126,8 +126,8 @@ class SubscriberEntity {
|
|||||||
private $linkToken;
|
private $linkToken;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="integer")
|
* @ORM\Column(type="float", nullable=true)
|
||||||
* @var int|null
|
* @var float|null
|
||||||
*/
|
*/
|
||||||
private $engagementScore;
|
private $engagementScore;
|
||||||
|
|
||||||
@ -410,16 +410,16 @@ class SubscriberEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return int|null
|
* @return float|null
|
||||||
*/
|
*/
|
||||||
public function getEngagementScore(): ?int {
|
public function getEngagementScore(): ?float {
|
||||||
return $this->engagementScore;
|
return $this->engagementScore;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int|null $engagementScore
|
* @param float|null $engagementScore
|
||||||
*/
|
*/
|
||||||
public function setEngagementScore(?int $engagementScore): void {
|
public function setEngagementScore(?float $engagementScore): void {
|
||||||
$this->engagementScore = $engagementScore;
|
$this->engagementScore = $engagementScore;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ use MailPoet\Entities\SubscriberEntity;
|
|||||||
use MailPoet\Tasks\Sending;
|
use MailPoet\Tasks\Sending;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @extends Repository<StatisticsOpensEntity>
|
* @extends Repository<StatisticsOpenEntity>
|
||||||
*/
|
*/
|
||||||
class StatisticsOpensRepository extends Repository {
|
class StatisticsOpensRepository extends Repository {
|
||||||
protected function getEntityClassName(): string {
|
protected function getEntityClassName(): string {
|
||||||
@ -43,7 +43,7 @@ class StatisticsOpensRepository extends Repository {
|
|||||||
->setParameter('subscriberId', $subscriber)
|
->setParameter('subscriberId', $subscriber)
|
||||||
->getQuery()
|
->getQuery()
|
||||||
->getSingleScalarResult();
|
->getSingleScalarResult();
|
||||||
$score = (int)round(($opens / $newslettersSentCount) * 100);
|
$score = ($opens / $newslettersSentCount) * 100;
|
||||||
$subscriber->setEngagementScore($score);
|
$subscriber->setEngagementScore($score);
|
||||||
$this->entityManager->flush();
|
$this->entityManager->flush();
|
||||||
}
|
}
|
||||||
|
@ -33,16 +33,21 @@ class Clicks {
|
|||||||
/** @var LinkShortcodeCategory */
|
/** @var LinkShortcodeCategory */
|
||||||
private $linkShortcodeCategory;
|
private $linkShortcodeCategory;
|
||||||
|
|
||||||
|
/** @var Opens */
|
||||||
|
private $opens;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
SettingsController $settingsController,
|
SettingsController $settingsController,
|
||||||
Cookies $cookies,
|
Cookies $cookies,
|
||||||
Shortcodes $shortcodes,
|
Shortcodes $shortcodes,
|
||||||
|
Opens $opens,
|
||||||
LinkShortcodeCategory $linkShortcodeCategory
|
LinkShortcodeCategory $linkShortcodeCategory
|
||||||
) {
|
) {
|
||||||
$this->settingsController = $settingsController;
|
$this->settingsController = $settingsController;
|
||||||
$this->cookies = $cookies;
|
$this->cookies = $cookies;
|
||||||
$this->shortcodes = $shortcodes;
|
$this->shortcodes = $shortcodes;
|
||||||
$this->linkShortcodeCategory = $linkShortcodeCategory;
|
$this->linkShortcodeCategory = $linkShortcodeCategory;
|
||||||
|
$this->opens = $opens;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -73,8 +78,7 @@ class Clicks {
|
|||||||
$this->sendRevenueCookie($statisticsClicks);
|
$this->sendRevenueCookie($statisticsClicks);
|
||||||
$this->sendAbandonedCartCookie($subscriber);
|
$this->sendAbandonedCartCookie($subscriber);
|
||||||
// track open event
|
// track open event
|
||||||
$openEvent = new Opens();
|
$this->opens->track($data, $displayImage = false);
|
||||||
$openEvent->track($data, $displayImage = false);
|
|
||||||
}
|
}
|
||||||
$url = $this->processUrl($link->getUrl(), $newsletter, $subscriber, $queue, $wpUserPreview);
|
$url = $this->processUrl($link->getUrl(), $newsletter, $subscriber, $queue, $wpUserPreview);
|
||||||
$this->redirectToUrl($url);
|
$this->redirectToUrl($url);
|
||||||
|
@ -12,7 +12,7 @@ use MailPoet\Subscribers\SubscribersRepository;
|
|||||||
use MailPoet\Tasks\Sending;
|
use MailPoet\Tasks\Sending;
|
||||||
use MailPoetVendor\Carbon\CarbonImmutable;
|
use MailPoetVendor\Carbon\CarbonImmutable;
|
||||||
|
|
||||||
class StatisticsFormsRepositoryTest extends \MailPoetTest {
|
class StatisticsOpensRepositoryTest extends \MailPoetTest {
|
||||||
/** @var StatisticsOpensRepository */
|
/** @var StatisticsOpensRepository */
|
||||||
private $repository;
|
private $repository;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user