![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/mautic.corals.io/app/bundles/EmailBundle/Entity/ |
<?php namespace Mautic\EmailBundle\Entity; use Mautic\CoreBundle\Entity\CommonRepository; use Mautic\CoreBundle\Helper\DateTimeHelper; /** * @extends CommonRepository<StatDevice> */ class StatDeviceRepository extends CommonRepository { public function getDeviceStats($emailIds, \DateTime $fromDate = null, \DateTime $toDate = null): array { $qb = $this->getEntityManager()->getConnection()->createQueryBuilder(); $qb->select('count(es.id) as count, d.device as device, es.list_id') ->from(MAUTIC_TABLE_PREFIX.'email_stats_devices', 'ed') ->join('ed', MAUTIC_TABLE_PREFIX.'lead_devices', 'd', 'd.id = ed.device_id') ->join('ed', MAUTIC_TABLE_PREFIX.'email_stats', 'es', 'es.id = ed.stat_id'); if (null != $emailIds) { if (!is_array($emailIds)) { $emailIds = [(int) $emailIds]; } $qb->where( $qb->expr()->in('es.email_id', $emailIds) ); } $qb->groupBy('es.list_id, d.device'); if (null !== $fromDate) { // make sure the date is UTC $dt = new DateTimeHelper($fromDate); $qb->andWhere( $qb->expr()->gte('es.date_read', $qb->expr()->literal($dt->toUtcString())) ); } if (null !== $toDate) { // make sure the date is UTC $dt = new DateTimeHelper($toDate); $qb->andWhere( $qb->expr()->lte('es.date_read', $qb->expr()->literal($dt->toUtcString())) ); } return $qb->executeQuery()->fetchAllAssociative(); } }