Use the latest updated queue
[MAILPOET-3876]
This commit is contained in:
@ -187,7 +187,7 @@ class SendingQueue extends APIEndpoint {
|
||||
$newsletter = $this->newsletterRepository->findOneById($newsletterId);
|
||||
|
||||
if ($newsletter instanceof NewsletterEntity) {
|
||||
$queue = $newsletter->getLatestQueue();
|
||||
$queue = $newsletter->getLastUpdatedQueue();
|
||||
|
||||
if (!$queue instanceof SendingQueueEntity) {
|
||||
return $this->errorResponse([
|
||||
@ -217,7 +217,7 @@ class SendingQueue extends APIEndpoint {
|
||||
$newsletter = $this->newsletterRepository->findOneById($newsletterId);
|
||||
|
||||
if ($newsletter instanceof NewsletterEntity) {
|
||||
$queue = $newsletter->getLatestQueue();
|
||||
$queue = $newsletter->getLastUpdatedQueue();
|
||||
|
||||
if (!$queue instanceof SendingQueueEntity) {
|
||||
return $this->errorResponse([
|
||||
|
@ -454,16 +454,20 @@ class NewsletterEntity {
|
||||
return $this->queues;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SendingQueueEntity|null
|
||||
*/
|
||||
public function getLatestQueue() {
|
||||
public function getLatestQueue(): ?SendingQueueEntity {
|
||||
$criteria = new Criteria();
|
||||
$criteria->orderBy(['id' => Criteria::DESC]);
|
||||
$criteria->setMaxResults(1);
|
||||
return $this->queues->matching($criteria)->first() ?: null;
|
||||
}
|
||||
|
||||
public function getLastUpdatedQueue(): ?SendingQueueEntity {
|
||||
$criteria = new Criteria();
|
||||
$criteria->orderBy(['updatedAt' => Criteria::DESC]);
|
||||
$criteria->setMaxResults(1);
|
||||
return $this->queues->matching($criteria)->first() ?: null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, SendingQueueEntity>
|
||||
*/
|
||||
|
Reference in New Issue
Block a user