Fix subscribers' segment filter

[MAILPOET-4563]
This commit is contained in:
Jan Lysý
2022-08-16 15:41:06 +02:00
committed by Veljko V
parent 6f5ddca2e9
commit 3d4f7cc33f

View File

@@ -260,9 +260,7 @@ class SubscriberListingRepository extends ListingRepository {
$queryBuilder
->select('s')
->from(SegmentEntity::class, 's');
if ($group === 'trash') {
$queryBuilder->andWhere('s.deletedAt IS NOT NULL');
} else {
if ($group !== 'trash') {
$queryBuilder->andWhere('s.deletedAt IS NULL');
}
@@ -285,9 +283,13 @@ class SubscriberListingRepository extends ListingRepository {
} else {
$count = $this->subscribersCountsController->getSegmentStatisticsCount($segment);
}
$subscribersCount = (float)$count[$key];
// filter segments without subscribers
if (!$subscribersCount) {
continue;
}
$segmentList[] = [
'label' => sprintf('%s (%s)', $segment->getName(), number_format((float)$count[$key])),
'label' => sprintf('%s (%s)', $segment->getName(), number_format($subscribersCount)),
'value' => $segment->getId(),
];
}