diff --git a/mailpoet/lib/Newsletter/Statistics/NewsletterStatisticsRepository.php b/mailpoet/lib/Newsletter/Statistics/NewsletterStatisticsRepository.php index 3660f56ed4..da5d115187 100644 --- a/mailpoet/lib/Newsletter/Statistics/NewsletterStatisticsRepository.php +++ b/mailpoet/lib/Newsletter/Statistics/NewsletterStatisticsRepository.php @@ -202,6 +202,12 @@ class NewsletterStatisticsRepository extends Repository { $query->andWhere('q.createdAt BETWEEN :from AND :to') ->setParameter('from', $from) ->setParameter('to', $to); + } elseif ($from && $to === null) { + $query->andWhere('q.createdAt >= :from') + ->setParameter('from', $from); + } elseif ($from === null && $to) { + $query->andWhere('q.createdAt <= :to') + ->setParameter('to', $to); } $results = $query->getQuery() @@ -224,6 +230,12 @@ class NewsletterStatisticsRepository extends Repository { $qb->andWhere('stats.createdAt BETWEEN :from AND :to') ->setParameter('from', $from) ->setParameter('to', $to); + } elseif ($from && $to === null) { + $qb->andWhere('stats.createdAt >= :from') + ->setParameter('from', $from); + } elseif ($from === null && $to) { + $qb->andWhere('stats.createdAt <= :to') + ->setParameter('to', $to); } $results = $qb @@ -266,6 +278,12 @@ class NewsletterStatisticsRepository extends Repository { $query->andWhere('stats.createdAt BETWEEN :from AND :to') ->setParameter('from', $from) ->setParameter('to', $to); + } elseif ($from && $to === null) { + $query->andWhere('stats.createdAt >= :from') + ->setParameter('from', $from); + } elseif ($from === null && $to) { + $query->andWhere('stats.createdAt <= :to') + ->setParameter('to', $to); } $results = $query->getQuery()