mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-17 06:53:15 +00:00
port to 4.1 date with time on phraseanet
This commit is contained in:
@@ -5,7 +5,7 @@ namespace Alchemy\Phrasea\SearchEngine\Elastic\Search;
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\AST;
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\Exception\Exception;
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\FieldMapping;
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\Mapping;
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\RecordHelper;
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\Structure\Structure;
|
||||
use Hoa\Compiler\Llk\TreeNode;
|
||||
use Hoa\Visitor\Element;
|
||||
@@ -166,6 +166,12 @@ class QueryVisitor implements Visit
|
||||
$key = $node->getChild(0)->accept($this);
|
||||
$boundary = $node->getChild(1)->accept($this);
|
||||
|
||||
if ($this->isDateKey($key)) {
|
||||
if(($v = RecordHelper::sanitizeDate($boundary)) !== null) {
|
||||
$boundary = $v;
|
||||
}
|
||||
}
|
||||
|
||||
switch ($node->getId()) {
|
||||
case NodeTypes::LT_EXPR:
|
||||
return AST\KeyValue\RangeExpression::lessThan($key, $boundary);
|
||||
@@ -195,11 +201,15 @@ class QueryVisitor implements Visit
|
||||
try {
|
||||
// Try to create a range for incomplete dates
|
||||
$range = QueryHelper::getRangeFromDateString($right);
|
||||
return new AST\KeyValue\RangeExpression(
|
||||
$left,
|
||||
$range['from'], true,
|
||||
$range['to'], false
|
||||
);
|
||||
if ($range['from'] === $range['to']) {
|
||||
return new AST\KeyValue\EqualExpression($left, $range['from']);
|
||||
} else {
|
||||
return new AST\KeyValue\RangeExpression(
|
||||
$left,
|
||||
$range['from'], true,
|
||||
$range['to'], false
|
||||
);
|
||||
}
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
// Fall back to equal expression
|
||||
}
|
||||
|
Reference in New Issue
Block a user