Skip to content

Commit

Permalink
lighter link to memberships
Browse files Browse the repository at this point in the history
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
  • Loading branch information
ArtificialOwl authored and backportbot[bot] committed Feb 18, 2025
1 parent 4778b64 commit 96ca8da
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lib/CirclesQueryHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,29 @@ public function limitToInheritedMembers(
);
}

/**
* lighter version with small inner join
*/
public function limitToMemberships(
string $alias,
string $field,
IFederatedUser $federatedUser,
): void {
$this->queryBuilder->setDefaultSelectAlias($alias);
$expr = $this->queryBuilder->expr();
$aliasMembership = $this->queryBuilder->generateAlias(CoreQueryBuilder::HELPER, CoreQueryBuilder::MEMBERSHIPS, $options);

$this->queryBuilder->innerJoin(
$alias,
CoreRequestBuilder::TABLE_MEMBERSHIP,
$aliasMembership,
$expr->andX(
$this->queryBuilder->exprLimit('single_id', $federatedUser->getSingleId(), $aliasMembership),
$expr->eq($aliasMembership . '.circle_id', $alias . '.' . $field)
)
);
}


/**
* @param string $field
Expand Down

0 comments on commit 96ca8da

Please sign in to comment.