Always count WP user list towards the limit
[MAILPOET-3143]
This commit is contained in:
committed by
Veljko V
parent
8de40ffb99
commit
86add53c30
@ -37,24 +37,6 @@ class SubscribersRepository extends Repository {
|
|||||||
return (int)$query->getSingleScalarResult();
|
return (int)$query->getSingleScalarResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function getTotalSubscribersWithoutWPUsers() {
|
|
||||||
$query = $this->entityManager
|
|
||||||
->createQueryBuilder()
|
|
||||||
->select('count(n.id)')
|
|
||||||
->from(SubscriberEntity::class, 'n')
|
|
||||||
->where('n.deletedAt IS NULL AND n.status IN (:statuses) AND n.wpUserId IS NULL')
|
|
||||||
->setParameter('statuses', [
|
|
||||||
SubscriberEntity::STATUS_SUBSCRIBED,
|
|
||||||
SubscriberEntity::STATUS_UNCONFIRMED,
|
|
||||||
SubscriberEntity::STATUS_INACTIVE,
|
|
||||||
])
|
|
||||||
->getQuery();
|
|
||||||
return (int)$query->getSingleScalarResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function findBySegment(int $segmentId): array {
|
public function findBySegment(int $segmentId): array {
|
||||||
return $this->entityManager
|
return $this->entityManager
|
||||||
->createQueryBuilder()
|
->createQueryBuilder()
|
||||||
|
@ -35,9 +35,6 @@ class Subscribers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getSubscribersCount() {
|
public function getSubscribersCount() {
|
||||||
if ($this->hasPremiumSupport()) {
|
|
||||||
return $this->subscribersRepository->getTotalSubscribersWithoutWPUsers();
|
|
||||||
}
|
|
||||||
return $this->subscribersRepository->getTotalSubscribers();
|
return $this->subscribersRepository->getTotalSubscribers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ class SubscribersTest extends \MailPoetUnitTest {
|
|||||||
expect($subscribersFeature->check())->false();
|
expect($subscribersFeature->check())->false();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCheckReturnsFalseIfPremiumPremiumSupportAndReachedLimit() {
|
public function testCheckReturnsTrueIfPremiumSupportAndReachedLimit() {
|
||||||
$subscribersFeature = $this->constructWith([
|
$subscribersFeature = $this->constructWith([
|
||||||
'has_mss_key' => false,
|
'has_mss_key' => false,
|
||||||
'mss_key_state' => 'valid',
|
'mss_key_state' => 'valid',
|
||||||
@ -163,9 +163,8 @@ class SubscribersTest extends \MailPoetUnitTest {
|
|||||||
'premium_subscribers_limit' => 2500,
|
'premium_subscribers_limit' => 2500,
|
||||||
'mss_subscribers_limit' => 500,
|
'mss_subscribers_limit' => 500,
|
||||||
'support_tier' => 'premium',
|
'support_tier' => 'premium',
|
||||||
'subscribers_count_without_wp_users' => 10,
|
|
||||||
]);
|
]);
|
||||||
expect($subscribersFeature->check())->false();
|
expect($subscribersFeature->check())->true();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function constructWith($specs) {
|
private function constructWith($specs) {
|
||||||
@ -183,9 +182,6 @@ class SubscribersTest extends \MailPoetUnitTest {
|
|||||||
'getTotalSubscribers' => function() use($specs) {
|
'getTotalSubscribers' => function() use($specs) {
|
||||||
return $specs['subscribers_count'];
|
return $specs['subscribers_count'];
|
||||||
},
|
},
|
||||||
'getTotalSubscribersWithoutWPUsers' => function() use($specs) {
|
|
||||||
return $specs['subscribers_count_without_wp_users'];
|
|
||||||
},
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return new SubscribersFeature($settings, $subscribersRepository);
|
return new SubscribersFeature($settings, $subscribersRepository);
|
||||||
|
Reference in New Issue
Block a user