Change cron scheduling for SubscribersEngagementScore
[MAILPOET-3585]
This commit is contained in:
@ -8,6 +8,7 @@ use MailPoet\Entities\SubscriberCustomFieldEntity;
|
||||
use MailPoet\Entities\SubscriberEntity;
|
||||
use MailPoet\Entities\SubscriberSegmentEntity;
|
||||
use MailPoet\WP\Functions as WPFunctions;
|
||||
use MailPoetVendor\Carbon\Carbon;
|
||||
use MailPoetVendor\Doctrine\DBAL\Connection;
|
||||
use MailPoetVendor\Doctrine\ORM\EntityManager;
|
||||
use MailPoetVendor\Doctrine\ORM\Query\Expr\Join;
|
||||
@ -292,4 +293,17 @@ class SubscribersRepository extends Repository {
|
||||
}
|
||||
return $this->findOneBy(['wpUserId' => $wpUser->ID]);
|
||||
}
|
||||
|
||||
public function findByUpdatedScoreNotInLastMonth(int $limit): array {
|
||||
$dateTime = (new Carbon())->subMonths(1);
|
||||
return $this->entityManager->createQueryBuilder()
|
||||
->select('s')
|
||||
->from(SubscriberEntity::class, 's')
|
||||
->where('s.engagementScoreUpdatedAt IS NULL')
|
||||
->orWhere('s.engagementScoreUpdatedAt < :dateTime')
|
||||
->setParameter('dateTime', $dateTime)
|
||||
->getQuery()
|
||||
->setMaxResults($limit)
|
||||
->getResult();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user