mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-07 07:43:12 +08:00
Fixed query to count tags when a search term is present
This commit is contained in:
@@ -23,11 +23,18 @@ abstract class AbstractTagsPaginatorAdapter implements AdapterInterface
|
||||
|
||||
public function getNbResults(): int
|
||||
{
|
||||
return (int) $this->repo->matchSingleScalarResult(Spec::andX(
|
||||
// FIXME I don't think using Spec::selectNew is the correct thing here, ideally it should be Spec::select,
|
||||
// but seems to be the only way to use Spec::COUNT(...)
|
||||
$conditions = [
|
||||
// FIXME I don't think using Spec::selectNew is the correct thing in this context.
|
||||
// Ideally it should be Spec::select, but seems to be the only way to use Spec::COUNT(...).
|
||||
Spec::selectNew(Tag::class, Spec::COUNT('id', true)),
|
||||
new WithApiKeySpecsEnsuringJoin($this->apiKey),
|
||||
));
|
||||
];
|
||||
|
||||
$searchTerm = $this->params->searchTerm();
|
||||
if ($searchTerm !== null) {
|
||||
$conditions[] = Spec::like('name', $searchTerm);
|
||||
}
|
||||
|
||||
return (int) $this->repo->matchSingleScalarResult(Spec::andX(...$conditions));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user