Create constant representing default domain identifier

This commit is contained in:
Alejandro Celaya
2024-10-28 08:36:06 +01:00
parent 1dd71d2ee7
commit 525a306ec6
13 changed files with 37 additions and 25 deletions

View File

@@ -25,6 +25,7 @@ class ShortUrlsCountFiltering
public readonly bool $excludePastValidUntil = false,
public readonly ?ApiKey $apiKey = null,
?string $defaultDomain = null,
public readonly ?string $domain = null,
) {
$this->searchIncludesDefaultDomain = !empty($searchTerm) && !empty($defaultDomain) && str_contains(
strtolower($defaultDomain),

View File

@@ -104,14 +104,13 @@ class ShortUrlListRepository extends EntitySpecificationRepository implements Sh
$searchTerm = $filtering->searchTerm;
$tags = $filtering->tags;
// Apply search term to every searchable field if not empty
if (! empty($searchTerm)) {
// Left join with tags only if no tags were provided. In case of tags, an inner join will be done later
if (empty($tags)) {
$qb->leftJoin('s.tags', 't');
}
// Apply general search conditions
// Apply search term to every "searchable" field
$conditions = [
$qb->expr()->like('s.longUrl', ':searchPattern'),
$qb->expr()->like('s.shortCode', ':searchPattern'),
@@ -142,6 +141,9 @@ class ShortUrlListRepository extends EntitySpecificationRepository implements Sh
: $this->joinAllTags($qb, $tags);
}
if ($filtering->domain !== null) {
}
if ($filtering->excludeMaxVisitsReached) {
$qb->andWhere($qb->expr()->orX(
$qb->expr()->isNull('s.maxVisits'),