Add support for clicked any to email type segment filter
[MAILPOET-3223]
This commit is contained in:
committed by
Veljko V
parent
841a7ab899
commit
4bfbfada6e
@@ -14,6 +14,7 @@ class EmailAction implements Filter {
|
||||
const ACTION_OPENED = 'opened';
|
||||
const ACTION_NOT_OPENED = 'notOpened';
|
||||
const ACTION_CLICKED = 'clicked';
|
||||
const ACTION_CLICKED_ANY = 'clickedAny';
|
||||
const ACTION_NOT_CLICKED = 'notClicked';
|
||||
|
||||
const ALLOWED_ACTIONS = [
|
||||
@@ -21,9 +22,16 @@ class EmailAction implements Filter {
|
||||
self::ACTION_NOT_OPENED,
|
||||
self::ACTION_CLICKED,
|
||||
self::ACTION_NOT_CLICKED,
|
||||
self::ACTION_CLICKED_ANY,
|
||||
EmailOpensAbsoluteCountAction::TYPE,
|
||||
];
|
||||
|
||||
const CLICK_ACTIONS = [
|
||||
self::ACTION_CLICKED,
|
||||
self::ACTION_NOT_CLICKED,
|
||||
self::ACTION_CLICKED_ANY,
|
||||
];
|
||||
|
||||
/** @var EntityManager */
|
||||
private $entityManager;
|
||||
|
||||
@@ -39,7 +47,7 @@ class EmailAction implements Filter {
|
||||
|
||||
$statsSentTable = $this->entityManager->getClassMetadata(StatisticsNewsletterEntity::class)->getTableName();
|
||||
$subscribersTable = $this->entityManager->getClassMetadata(SubscriberEntity::class)->getTableName();
|
||||
if (($action === self::ACTION_CLICKED) || ($action === self::ACTION_NOT_CLICKED)) {
|
||||
if (in_array($action, self::CLICK_ACTIONS, true)) {
|
||||
$statsTable = $this->entityManager->getClassMetadata(StatisticsClickEntity::class)->getTableName();
|
||||
} else {
|
||||
$statsTable = $this->entityManager->getClassMetadata(StatisticsOpenEntity::class)->getTableName();
|
||||
@@ -58,22 +66,27 @@ class EmailAction implements Filter {
|
||||
$statsTable,
|
||||
'stats',
|
||||
$this->createNotStatsJoinCondition($filter, $action, $linkId)
|
||||
);
|
||||
)->setParameter('newsletter' . $filter->getId(), $newsletterId);
|
||||
$where .= ' AND stats.id IS NULL';
|
||||
} else if ($action === self::ACTION_CLICKED_ANY) {
|
||||
$queryBuilder = $queryBuilder->innerJoin(
|
||||
$subscribersTable,
|
||||
$statsTable,
|
||||
'stats',
|
||||
"stats.subscriber_id = $subscribersTable.id"
|
||||
);
|
||||
} else {
|
||||
$queryBuilder = $queryBuilder->innerJoin(
|
||||
$subscribersTable,
|
||||
$statsTable,
|
||||
'stats',
|
||||
"stats.subscriber_id = $subscribersTable.id AND stats.newsletter_id = :newsletter" . $filter->getId()
|
||||
);
|
||||
)->setParameter('newsletter' . $filter->getId(), $newsletterId);
|
||||
}
|
||||
if ($action === EmailAction::ACTION_CLICKED && $linkId) {
|
||||
$where .= ' AND stats.link_id = :link' . $filter->getId();
|
||||
}
|
||||
$queryBuilder = $queryBuilder
|
||||
->andWhere($where)
|
||||
->setParameter('newsletter' . $filter->getId(), $newsletterId);
|
||||
$queryBuilder = $queryBuilder->andWhere($where);
|
||||
if (in_array($action, [EmailAction::ACTION_CLICKED, EmailAction::ACTION_NOT_CLICKED]) && $linkId) {
|
||||
$queryBuilder = $queryBuilder
|
||||
->setParameter('link' . $filter->getId(), $linkId);
|
||||
|
Reference in New Issue
Block a user