mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-08 08:13:11 +08:00
Update to doctrine ORM 3.0
This commit is contained in:
@@ -55,15 +55,15 @@ class ShortUrlListRepository extends EntitySpecificationRepository implements Sh
|
||||
if (OrderableField::isBasicField($fieldName)) {
|
||||
$qb->orderBy('s.' . $fieldName, $order);
|
||||
} elseif (OrderableField::isVisitsField($fieldName)) {
|
||||
$leftJoinConditions = [$qb->expr()->eq('v.shortUrl', 's')];
|
||||
if ($fieldName === OrderableField::NON_BOT_VISITS->value) {
|
||||
$leftJoinConditions[] = $qb->expr()->eq('v.potentialBot', 'false');
|
||||
}
|
||||
|
||||
// FIXME This query is inefficient.
|
||||
// Diagnostic: It might need to use a sub-query, as done with the tags list query.
|
||||
$qb->addSelect('COUNT(DISTINCT v)')
|
||||
->leftJoin('s.visits', 'v', Join::WITH, $qb->expr()->andX(
|
||||
$qb->expr()->eq('v.shortUrl', 's'),
|
||||
$fieldName === OrderableField::NON_BOT_VISITS->value
|
||||
? $qb->expr()->eq('v.potentialBot', 'false')
|
||||
: null,
|
||||
))
|
||||
->leftJoin('s.visits', 'v', Join::WITH, $qb->expr()->andX(...$leftJoinConditions))
|
||||
->groupBy('s')
|
||||
->orderBy('COUNT(DISTINCT v)', $order);
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ class ShortUrlRepository extends EntitySpecificationRepository implements ShortU
|
||||
/**
|
||||
* @param LockMode::PESSIMISTIC_WRITE|null $lockMode
|
||||
*/
|
||||
private function doShortCodeIsInUse(ShortUrlIdentifier $identifier, ?Specification $spec, ?int $lockMode): bool
|
||||
private function doShortCodeIsInUse(ShortUrlIdentifier $identifier, ?Specification $spec, ?LockMode $lockMode): bool
|
||||
{
|
||||
$qb = $this->createFindOneQueryBuilder($identifier, $spec)->select('s.id');
|
||||
$query = $qb->getQuery();
|
||||
|
||||
@@ -79,6 +79,7 @@ class PersistenceShortUrlRelationResolver implements ShortUrlRelationResolverInt
|
||||
return new Collections\ArrayCollection(array_map(function (string $tagName) use ($repo): Tag {
|
||||
$this->lock($this->tagLocks, 'tag_' . $tagName);
|
||||
|
||||
/** @var Tag|null $existingTag */
|
||||
$existingTag = $repo->findOneBy(['name' => $tagName]);
|
||||
if ($existingTag) {
|
||||
$this->releaseLock($this->tagLocks, 'tag_' . $tagName);
|
||||
|
||||
@@ -82,12 +82,12 @@ class TagRepository extends EntitySpecificationRepository implements TagReposito
|
||||
: $visitsSubQb->expr()->and(
|
||||
$commonJoinCondition,
|
||||
$visitsSubQb->expr()->eq('v.potential_bot', $conn->quote('0')),
|
||||
);
|
||||
)->__toString();
|
||||
|
||||
return $visitsSubQb
|
||||
->select('st.tag_id AS tag_id', 'COUNT(DISTINCT v.id) AS ' . $aggregateAlias)
|
||||
->from('visits', 'v')
|
||||
->join('v', 'short_urls', 's', $visitsJoin) // @phpstan-ignore-line
|
||||
->join('v', 'short_urls', 's', $visitsJoin)
|
||||
->join('s', 'short_urls_in_tags', 'st', $visitsSubQb->expr()->eq('st.short_url_id', 's.id'))
|
||||
->groupBy('st.tag_id');
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user