Add calculation segment score

[MAILPOET-3533]
This commit is contained in:
Jan Lysý
2021-05-05 08:50:00 +02:00
committed by Veljko V
parent a92943ff30
commit 6d0486cfc5
5 changed files with 105 additions and 7 deletions

View File

@@ -184,4 +184,17 @@ class SegmentsRepository extends Repository {
return $rows;
}
public function findByUpdatedScoreNotInLastMonth(int $limit): array {
$dateTime = (new Carbon())->subMonths(1);
return $this->entityManager->createQueryBuilder()
->select('s')
->from(SegmentEntity::class, 's')
->where('s.averageEngagementScoreUpdatedAt IS NULL')
->orWhere('s.averageEngagementScoreUpdatedAt < :dateTime')
->setParameter('dateTime', $dateTime)
->getQuery()
->setMaxResults($limit)
->getResult();
}
}