| @@ 13-26 (lines=14) @@ | ||
| 10 | ||
| 11 | class JobManager extends BaseJobManager |
|
| 12 | { |
|
| 13 | public function countJobsByStatus($objectName, $status, $workerName = null, $method = null) |
|
| 14 | { |
|
| 15 | /** @var DocumentManager $objectManager */ |
|
| 16 | $objectManager = $this->getObjectManager(); |
|
| 17 | $qb = $objectManager->createQueryBuilder($objectName); |
|
| 18 | $qb |
|
| 19 | ->find() |
|
| 20 | ->field('status')->equals($status); |
|
| 21 | ||
| 22 | $this->addWorkerNameCriterion($qb, $workerName, $method); |
|
| 23 | $query = $qb->getQuery(); |
|
| 24 | ||
| 25 | return $query->count(); |
|
| 26 | } |
|
| 27 | ||
| 28 | /** |
|
| 29 | * @param string $objectName |
|
| @@ 98-109 (lines=12) @@ | ||
| 95 | * |
|
| 96 | * @return int Count of jobs pruned |
|
| 97 | */ |
|
| 98 | protected function pruneJobs($workerName = null, $method = null, $objectName, $conditionFunc) |
|
| 99 | { |
|
| 100 | /** @var EntityManager $objectManager */ |
|
| 101 | $objectManager = $this->getObjectManager(); |
|
| 102 | $qb = $objectManager->createQueryBuilder()->delete($objectName, 'j'); |
|
| 103 | $conditionFunc($qb); |
|
| 104 | ||
| 105 | $this->addWorkerNameCriterion($qb, $workerName, $method); |
|
| 106 | $query = $qb->getQuery(); |
|
| 107 | ||
| 108 | return intval($query->execute()); |
|
| 109 | } |
|
| 110 | ||
| 111 | protected function addWorkerNameCriterion(QueryBuilder $queryBuilder, $workerName = null, $method = null) |
|
| 112 | { |
|