Add fetching of global subscribers stats to Homepage data controller
[MAILPOET-4828]
This commit is contained in:
committed by
Aschepikov
parent
9217f197f9
commit
ab35f5c8c1
@ -5,6 +5,7 @@ namespace MailPoet\Subscribers;
|
||||
use MailPoet\Config\SubscriberChangesNotifier;
|
||||
use MailPoet\Doctrine\Repository;
|
||||
use MailPoet\Entities\SegmentEntity;
|
||||
use MailPoet\Entities\StatisticsUnsubscribeEntity;
|
||||
use MailPoet\Entities\SubscriberCustomFieldEntity;
|
||||
use MailPoet\Entities\SubscriberEntity;
|
||||
use MailPoet\Entities\SubscriberSegmentEntity;
|
||||
@ -370,6 +371,35 @@ class SubscribersRepository extends Repository {
|
||||
return is_int($maxSubscriberId) ? $maxSubscriberId : 0;
|
||||
}
|
||||
|
||||
public function getCountOfCreatedAfterWithStatues(\DateTimeInterface $createdAfter, array $statuses): int {
|
||||
$result = $this->entityManager->createQueryBuilder()
|
||||
->select('COUNT(s.id)')
|
||||
->from(SubscriberEntity::class, 's')
|
||||
->where('s.createdAt > :createdAfter')
|
||||
->andWhere('s.status IN (:statuses)')
|
||||
->andWhere('s.deletedAt IS NULL')
|
||||
->setParameter('createdAfter', $createdAfter)
|
||||
->setParameter('statuses', $statuses)
|
||||
->getQuery()
|
||||
->getSingleScalarResult();
|
||||
return intval($result);
|
||||
}
|
||||
|
||||
public function getCountOfUnsubscribedAfter(\DateTimeInterface $unsubscribedAfter): int {
|
||||
$result = $this->entityManager->createQueryBuilder()
|
||||
->select('COUNT(s.id)')
|
||||
->from(StatisticsUnsubscribeEntity::class, 'su')
|
||||
->join('su.subscriber', 's')
|
||||
->where('s.createdAt > :unsubscribedAfter')
|
||||
->andWhere('s.status = :status')
|
||||
->andWhere('s.deletedAt IS NULL')
|
||||
->setParameter('unsubscribedAfter', $unsubscribedAfter)
|
||||
->setParameter('status', SubscriberEntity::STATUS_UNSUBSCRIBED)
|
||||
->getQuery()
|
||||
->getSingleScalarResult();
|
||||
return intval($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int - number of processed ids
|
||||
*/
|
||||
|
Reference in New Issue
Block a user