52 lines
1.4 KiB
PHP
52 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace MailPoet\Subscribers;
|
|
|
|
use MailPoet\Doctrine\Repository;
|
|
use MailPoet\Entities\SubscriberEntity;
|
|
|
|
/**
|
|
* @extends Repository<SubscriberEntity>
|
|
*/
|
|
class SubscribersRepository extends Repository {
|
|
protected function getEntityClassName() {
|
|
return SubscriberEntity::class;
|
|
}
|
|
|
|
/**
|
|
* @return int
|
|
*/
|
|
public function getTotalSubscribers() {
|
|
$query = $this->entityManager
|
|
->createQueryBuilder()
|
|
->select('count(n.id)')
|
|
->from(SubscriberEntity::class, 'n')
|
|
->where('n.deletedAt IS NULL AND n.status IN (:statuses)')
|
|
->setParameter('statuses', [
|
|
SubscriberEntity::STATUS_SUBSCRIBED,
|
|
SubscriberEntity::STATUS_UNCONFIRMED,
|
|
SubscriberEntity::STATUS_INACTIVE,
|
|
])
|
|
->getQuery();
|
|
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();
|
|
}
|
|
}
|