Optimize queries for statistics.

This commit is contained in:
James Cole
2025-09-26 06:05:37 +02:00
parent 08879d31ba
commit 4ec2fcdb8a
92 changed files with 6499 additions and 6514 deletions

View File

@@ -32,7 +32,6 @@ use Gdbots\QueryParser\QueryParser as BaseQueryParser;
use Illuminate\Support\Facades\Log;
use LogicException;
use TypeError;
use function Safe\fwrite;
class GdbotsQueryParser implements QueryParserInterface
@@ -52,12 +51,12 @@ class GdbotsQueryParser implements QueryParserInterface
try {
$result = $this->parser->parse($query);
$nodes = array_map(
fn (GdbotsNode\Node $node) => $this->convertNode($node),
fn(GdbotsNode\Node $node) => $this->convertNode($node),
$result->getNodes()
);
return new NodeGroup($nodes);
} catch (LogicException|TypeError $e) {
} catch (LogicException | TypeError $e) {
fwrite(STDERR, "Setting up GdbotsQueryParserTest\n");
app('log')->error($e->getMessage());
app('log')->error(sprintf('Could not parse search: "%s".', $query));
@@ -76,7 +75,7 @@ class GdbotsQueryParser implements QueryParserInterface
case $node instanceof GdbotsNode\Field:
return new FieldNode(
$node->getValue(),
(string) $node->getNode()->getValue(),
(string)$node->getNode()->getValue(),
BoolOperator::PROHIBITED === $node->getBoolOperator()
);
@@ -85,7 +84,7 @@ class GdbotsQueryParser implements QueryParserInterface
return new NodeGroup(
array_map(
fn (GdbotsNode\Node $subNode) => $this->convertNode($subNode),
fn(GdbotsNode\Node $subNode) => $this->convertNode($subNode),
$node->getNodes()
)
);
@@ -98,7 +97,7 @@ class GdbotsQueryParser implements QueryParserInterface
case $node instanceof GdbotsNode\Mention:
case $node instanceof GdbotsNode\Emoticon:
case $node instanceof GdbotsNode\Emoji:
return new StringNode((string) $node->getValue(), BoolOperator::PROHIBITED === $node->getBoolOperator());
return new StringNode((string)$node->getValue(), BoolOperator::PROHIBITED === $node->getBoolOperator());
default:
throw new FireflyException(