fix filtering of new tasks

This commit is contained in:
Julien Fastré 2021-10-28 01:05:36 +02:00
parent e63d645f8a
commit 4da32dc5ca
3 changed files with 43 additions and 0 deletions

View File

@ -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' => [

View File

@ -0,0 +1,35 @@
<?php
/*
*
*
*/
namespace Chill\MainBundle\Doctrine\DQL;
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\Parser;
use Doctrine\ORM\Query\SqlWalker;
/**
* Return the length of an array
*/
class JsonbArrayLength extends FunctionNode
{
private $expr1;
public function getSql(SqlWalker $sqlWalker): string
{
return sprintf(
'jsonb_array_length(%s)',
$this->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);
}
}

View File

@ -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