createQueryBuilder('e'); $qb ->where($qb->expr()->eq('e.delivered', $qb->expr()->literal(false))) ->andWhere($qb->expr()->lt('e.deliveryTries', ':nb_tries')); $qb->setParameter(':nb_tries', WebhookEventDelivery::MAX_DELIVERY_TRIES); return $qb->getQuery()->getResult(); } /** * @param $apiApplication * @return WebhookEventDelivery[] */ public function findUndeliveredEventsFromLastAppUpdate(ApiApplication $apiApplication) { $qb = $this->createQueryBuilder('e'); $qb ->join('e.application', 'a') ->where('e.application = :app') ->andWhere($qb->expr()->eq('e.delivered', $qb->expr()->literal(false))) ->andWhere('e.deliveryTries = 3') ->andWhere('e.created > a.updated') ->setParameter(':app', $apiApplication) ; return $qb->getQuery()->getResult(); } /** * @param ApiApplication $apiApplication * @param int $count * @return WebhookEventDelivery[] */ public function findLastDeliveries(ApiApplication $apiApplication, $count = 10) { $qb = $this->createQueryBuilder('e'); $qb ->where('e.application = :app') ->setMaxResults(max(0, (int) $count)) ->orderBy('e.created', 'DESC') ->setParameters([ 'app' => $apiApplication ]); return $qb->getQuery()->getResult(); } }