Simplify fetching a single result from database
[MAILPOET-2439]
This commit is contained in:
committed by
Jack Kitterhing
parent
20ad724a98
commit
ac9761228a
@ -12,9 +12,7 @@ class NewsletterLinkRepository extends Repository {
|
||||
|
||||
/**
|
||||
* @param int $newsletter_id
|
||||
* @return NewsletterLinkEntity
|
||||
* @throws \MailPoetVendor\Doctrine\ORM\NoResultException
|
||||
* @throws \MailPoetVendor\Doctrine\ORM\NonUniqueResultException
|
||||
* @return NewsletterLinkEntity|null
|
||||
*/
|
||||
public function findTopLinkForNewsletter($newsletter_id) {
|
||||
return $this->doctrine_repository
|
||||
@ -27,7 +25,7 @@ class NewsletterLinkRepository extends Repository {
|
||||
->orderBy('counter', 'desc')
|
||||
->setMaxResults(1)
|
||||
->getQuery()
|
||||
->getSingleResult();
|
||||
->getOneOrNullResult();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -102,11 +102,7 @@ class Worker {
|
||||
|
||||
private function constructNewsletter(StatsNotificationEntity $stats_notification_entity) {
|
||||
$newsletter = $stats_notification_entity->getNewsletter();
|
||||
try {
|
||||
$link = $this->newsletter_link_repository->findTopLinkForNewsletter($newsletter->getId());
|
||||
} catch (\MailPoetVendor\Doctrine\ORM\UnexpectedResultException $e) {
|
||||
$link = null;
|
||||
}
|
||||
$context = $this->prepareContext($newsletter, $link);
|
||||
$subject = $newsletter->getLatestQueue()->getNewsletterRenderedSubject();
|
||||
return [
|
||||
|
Reference in New Issue
Block a user