mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-26 08:35:00 +00:00
Fix Canceling of stale workflow cronjob
Refactor workflow cancellation logic to encapsulate transition checks in a dedicated method, and update CronJob handling to use entity workflows instead of IDs. Enhance test coverage to ensure proper handling and instantiate mocks for EntityManagerInterface.
This commit is contained in:
@@ -205,13 +205,13 @@ class EntityWorkflowRepository implements ObjectRepository
|
||||
*
|
||||
* @param \DateTimeImmutable $olderThanDate the date to compare against
|
||||
*
|
||||
* @return list<int> the list of workflow IDs that meet the criteria
|
||||
* @return iterable<EntityWorkflow>
|
||||
*/
|
||||
public function findWorkflowsWithoutFinalStepAndOlderThan(\DateTimeImmutable $olderThanDate): array
|
||||
public function findWorkflowsWithoutFinalStepAndOlderThan(\DateTimeImmutable $olderThanDate): iterable
|
||||
{
|
||||
$qb = $this->repository->createQueryBuilder('sw');
|
||||
|
||||
$qb->select('sw.id')
|
||||
$qb->select('sw')
|
||||
// only the workflow which are not finalized
|
||||
->where(sprintf('NOT EXISTS (SELECT 1 FROM %s ews WHERE ews.isFinal = TRUE AND ews.entityWorkflow = sw.id)', EntityWorkflowStep::class))
|
||||
->andWhere(
|
||||
@@ -227,7 +227,7 @@ class EntityWorkflowRepository implements ObjectRepository
|
||||
->setParameter('initial', 'initial')
|
||||
;
|
||||
|
||||
return $qb->getQuery()->getResult();
|
||||
return $qb->getQuery()->toIterable();
|
||||
}
|
||||
|
||||
public function getClassName(): string
|
||||
|
Reference in New Issue
Block a user