From 1ba9b25ff004173b20b11091c84261d1162abf78 Mon Sep 17 00:00:00 2001 From: Marco Petersen Date: Mon, 9 Mar 2020 14:15:33 +0100 Subject: [PATCH] Limit the number of jobs to fetch to 1 --- Entity/Repository/JobManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Entity/Repository/JobManager.php b/Entity/Repository/JobManager.php index 78e66ef7..fb74379c 100644 --- a/Entity/Repository/JobManager.php +++ b/Entity/Repository/JobManager.php @@ -155,7 +155,7 @@ public function findJobForRelatedEntity($command, $relatedEntity, array $states $rsm = new ResultSetMappingBuilder($this->getJobManager()); $rsm->addRootEntityFromClassMetadata('JMSJobQueueBundle:Job', 'j'); - $sql = "SELECT j.* FROM jms_jobs j INNER JOIN jms_job_related_entities r ON r.job_id = j.id WHERE r.related_class = :relClass AND r.related_id = :relId AND j.command = :command"; + $sql = "SELECT j.* FROM jms_jobs j INNER JOIN jms_job_related_entities r ON r.job_id = j.id WHERE r.related_class = :relClass AND r.related_id = :relId AND j.command = :command LIMIT 1"; $params = new ArrayCollection(); $params->add(new Parameter('command', $command)); $params->add(new Parameter('relClass', $relClass));