Merged in fix/empty_query_search (pull request #51)

Optimizing empty search query a bit.
This commit is contained in:
Alexey Eschenko 2020-12-19 21:37:02 +00:00
commit 387a44722e

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).'%');
}