Fix filtering subscribers without segment
[MAILPOET-3197]
This commit is contained in:
@ -16,6 +16,8 @@ use MailPoetVendor\Doctrine\ORM\Query\Expr\Join;
|
|||||||
use MailPoetVendor\Doctrine\ORM\QueryBuilder;
|
use MailPoetVendor\Doctrine\ORM\QueryBuilder;
|
||||||
|
|
||||||
class SubscriberListingRepository extends ListingRepository {
|
class SubscriberListingRepository extends ListingRepository {
|
||||||
|
public const FILTER_WITHOUT_LIST = 'without-list';
|
||||||
|
|
||||||
const DEFAULT_SORT_BY = 'createdAt';
|
const DEFAULT_SORT_BY = 'createdAt';
|
||||||
|
|
||||||
private static $supportedStatuses = [
|
private static $supportedStatuses = [
|
||||||
@ -88,6 +90,14 @@ class SubscriberListingRepository extends ListingRepository {
|
|||||||
if (!$filters || !isset($filters['segment'])) {
|
if (!$filters || !isset($filters['segment'])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if ($filters['segment'] === self::FILTER_WITHOUT_LIST) {
|
||||||
|
$queryBuilder->leftJoin('s.subscriberSegments', 'ssg', Join::WITH, (string)$queryBuilder->expr()->eq('ssg.status', ':statusSubscribed'))
|
||||||
|
->leftJoin('ssg.segment', 'sg', Join::WITH, (string)$queryBuilder->expr()->isNull('sg.deletedAt'))
|
||||||
|
->andWhere('s.deletedAt IS NULL')
|
||||||
|
->andWhere('sg.id IS NULL')
|
||||||
|
->setParameter('statusSubscribed', SubscriberEntity::STATUS_SUBSCRIBED);
|
||||||
|
return;
|
||||||
|
}
|
||||||
$segment = $this->entityManager->find(SegmentEntity::class, (int)$filters['segment']);
|
$segment = $this->entityManager->find(SegmentEntity::class, (int)$filters['segment']);
|
||||||
if (!$segment instanceof SegmentEntity) {
|
if (!$segment instanceof SegmentEntity) {
|
||||||
return;
|
return;
|
||||||
@ -218,7 +228,7 @@ class SubscriberListingRepository extends ListingRepository {
|
|||||||
|
|
||||||
$withoutSegmentList = [
|
$withoutSegmentList = [
|
||||||
'label' => $subscribersWithoutSegmentLabel,
|
'label' => $subscribersWithoutSegmentLabel,
|
||||||
'value' => 'none',
|
'value' => self::FILTER_WITHOUT_LIST,
|
||||||
];
|
];
|
||||||
|
|
||||||
$segmentList = [];
|
$segmentList = [];
|
||||||
|
Reference in New Issue
Block a user