From 4da32dc5cac7becd4be69cef239b7e0ba59a392d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 28 Oct 2021 01:05:36 +0200 Subject: [PATCH] fix filtering of new tasks --- .../ChillMainExtension.php | 2 ++ .../Doctrine/DQL/JsonbArrayLength.php | 35 +++++++++++++++++++ .../SingleTaskAclAwareRepository.php | 6 ++++ 3 files changed, 43 insertions(+) create mode 100644 src/Bundle/ChillMainBundle/Doctrine/DQL/JsonbArrayLength.php diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php index c90638893..7b2f0a3a1 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php @@ -23,6 +23,7 @@ use Chill\MainBundle\Controller\AddressApiController; use Chill\MainBundle\Controller\LocationController; use Chill\MainBundle\Controller\LocationTypeController; use Chill\MainBundle\Controller\UserController; +use Chill\MainBundle\Doctrine\DQL\JsonbArrayLength; use Chill\MainBundle\Doctrine\DQL\STContains; use Chill\MainBundle\Doctrine\DQL\StrictWordSimilarityOPS; use Chill\MainBundle\Entity\User; @@ -203,6 +204,7 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface, 'OVERLAPSI' => OverlapsI::class, 'STRICT_WORD_SIMILARITY_OPS' => StrictWordSimilarityOPS::class, 'ST_CONTAINS' => STContains::class, + 'JSONB_ARRAY_LENGTH' => JsonbArrayLength::class, ], ], 'hydrators' => [ diff --git a/src/Bundle/ChillMainBundle/Doctrine/DQL/JsonbArrayLength.php b/src/Bundle/ChillMainBundle/Doctrine/DQL/JsonbArrayLength.php new file mode 100644 index 000000000..39049748c --- /dev/null +++ b/src/Bundle/ChillMainBundle/Doctrine/DQL/JsonbArrayLength.php @@ -0,0 +1,35 @@ +expr1->dispatch($sqlWalker), + ); + } + + public function parse(Parser $parser): void + { + $parser->match(Lexer::T_IDENTIFIER); + $parser->match(Lexer::T_OPEN_PARENTHESIS); + $this->expr1 = $parser->StringPrimary(); + $parser->match(Lexer::T_CLOSE_PARENTHESIS); + } +} diff --git a/src/Bundle/ChillTaskBundle/Repository/SingleTaskAclAwareRepository.php b/src/Bundle/ChillTaskBundle/Repository/SingleTaskAclAwareRepository.php index 2e5b8d803..bc5124d95 100644 --- a/src/Bundle/ChillTaskBundle/Repository/SingleTaskAclAwareRepository.php +++ b/src/Bundle/ChillTaskBundle/Repository/SingleTaskAclAwareRepository.php @@ -110,6 +110,12 @@ final class SingleTaskAclAwareRepository implements SingleTaskAclAwareRepository $qb ->setParameter('now', $now); break; + case 'state_new': + $orXState + ->add( + "JSONB_ARRAY_LENGTH(t.currentStates) = 0" + ); + break; case \substr($flag, 0, 6) === 'state_': $state = \substr($flag, 6); $orXState