mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-26 08:35:00 +00:00
Add cronjob and repository method to find and cancel stale workflows every other day
This commit is contained in:
@@ -198,6 +198,19 @@ class EntityWorkflowRepository implements ObjectRepository
|
||||
return $this->repository->findOneBy($criteria);
|
||||
}
|
||||
|
||||
public function findWorkflowsWithoutFinalStepAndOlderThan(\DateTimeImmutable $olderThanDate)
|
||||
{
|
||||
$qb = $this->repository->createQueryBuilder('sw');
|
||||
|
||||
$qb->select('sw.id')
|
||||
->where('NOT EXISTS (SELECT 1 FROM chill_main_entity_workflow_step ews WHERE ews.isFinal = TRUE AND ews.entityWorkflow = sw.id)')
|
||||
->andWhere(':olderThanDate > ALL (SELECT ews.transitionAt FROM chill_main_entity_workflow_step ews WHERE ews.transitionAt IS NOT NULL AND ews.entityWorkflow = sw.id)')
|
||||
->andWhere('sw.createdAt < :olderThanDate')
|
||||
->setParameter('olderThanDate', $olderThanDate);
|
||||
|
||||
return $qb->getQuery()->getResult();
|
||||
}
|
||||
|
||||
public function getClassName(): string
|
||||
{
|
||||
return EntityWorkflow::class;
|
||||
|
Reference in New Issue
Block a user