Optimizing empty search query a bit.

This commit is contained in:
Alexey Skobkin 2020-12-20 00:35:57 +03:00
parent d4479189d3
commit 669095e907
No known key found for this signature in database
GPG Key ID: 5D5CEF6F221278E7
1 changed files with 7 additions and 1 deletions

View File

@ -39,9 +39,15 @@ class TorrentSearcher
{
$qb = $this->torrentRepo->createQueryBuilder('t');
$queryParts = $this->splitQueryToParts($query);
if (count($queryParts) < 1) {
return $qb;
}
$where = $qb->expr()->andX();
foreach ($this->splitQueryToParts($query) as $idx => $part) {
foreach ($queryParts as $idx => $part) {
$where->add('ILIKE(t.name , :part_'.$idx.') = TRUE');
$qb->setParameter('part_'.$idx, '%'.strtolower($part).'%');
}