mirror of
https://github.com/netzbegruenung/circles.git
synced 2024-04-28 18:04:51 +02:00
Fix not using index on short id
This commit is contained in:
parent
6fb39a4b3e
commit
2edb05eb9e
|
@ -226,7 +226,7 @@ class CircleProviderRequestBuilder extends CoreRequestBuilder {
|
|||
|
||||
$tmpOrX = $expr->eq(
|
||||
's.share_with',
|
||||
$qb->createFunction('SUBSTR(`c`.`unique_id`, 1, ' . Circle::SHORT_UNIQUE_ID_LENGTH . ')')
|
||||
'c.unique_short_id'
|
||||
);
|
||||
|
||||
if ($shareId === -1) {
|
||||
|
@ -257,7 +257,7 @@ class CircleProviderRequestBuilder extends CoreRequestBuilder {
|
|||
'c', CoreRequestBuilder::TABLE_MEMBERS, 'mo', $expr->andX(
|
||||
$expr->eq(
|
||||
'mo.circle_id',
|
||||
$qb->createFunction('SUBSTR(`c`.`unique_id`, 1, ' . Circle::SHORT_UNIQUE_ID_LENGTH . ')')
|
||||
'c.unique_short_id'
|
||||
), $expr->eq('mo.user_type', $qb->createNamedParameter(Member::TYPE_USER)),
|
||||
$expr->eq('mo.level', $qb->createNamedParameter(Member::LEVEL_OWNER))
|
||||
)
|
||||
|
@ -307,9 +307,7 @@ class CircleProviderRequestBuilder extends CoreRequestBuilder {
|
|||
$andX->add(
|
||||
$expr->eq(
|
||||
'm.circle_id',
|
||||
$qb->createFunction(
|
||||
'SUBSTR(`c`.`unique_id`, 1, ' . Circle::SHORT_UNIQUE_ID_LENGTH . ')'
|
||||
)
|
||||
'c.unique_short_id'
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -334,7 +332,7 @@ class CircleProviderRequestBuilder extends CoreRequestBuilder {
|
|||
$expr->andX(
|
||||
$expr->eq(
|
||||
'g.circle_id',
|
||||
$qb->createFunction('SUBSTR(`c`.`unique_id`, 1, ' . Circle::SHORT_UNIQUE_ID_LENGTH . ')')
|
||||
'c.unique_short_id'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
|
|
@ -143,7 +143,7 @@ class CirclesRequest extends CirclesRequestBuilder {
|
|||
$qb = $this->getCirclesSelectSql();
|
||||
$this->leftJoinUserIdAsViewer($qb, $userId);
|
||||
$this->leftJoinOwner($qb);
|
||||
$this->leftJoinNCGroupAndUser($qb, $userId, '`c`.`unique_id`');
|
||||
$this->leftJoinNCGroupAndUser($qb, $userId, 'c.unique_short_id');
|
||||
|
||||
if ($level > 0) {
|
||||
$this->limitToLevel($qb, $level, ['u', 'g']);
|
||||
|
@ -178,7 +178,7 @@ class CirclesRequest extends CirclesRequestBuilder {
|
|||
|
||||
$this->leftJoinUserIdAsViewer($qb, $viewerId);
|
||||
$this->leftJoinOwner($qb);
|
||||
$this->leftJoinNCGroupAndUser($qb, $viewerId, '`c`.`unique_id`');
|
||||
$this->leftJoinNCGroupAndUser($qb, $viewerId, 'c.unique_short_id');
|
||||
|
||||
$this->limitRegardingCircleType($qb, $viewerId, $circleUniqueId, Circle::CIRCLES_ALL, '');
|
||||
|
||||
|
|
|
@ -180,9 +180,7 @@ class CirclesRequestBuilder extends CoreRequestBuilder {
|
|||
->add(
|
||||
$expr->eq(
|
||||
$qb->createNamedParameter($circleUniqueId),
|
||||
$qb->createFunction(
|
||||
'SUBSTR(`c`.`unique_id`, 1, ' . Circle::SHORT_UNIQUE_ID_LENGTH . ')'
|
||||
)
|
||||
'c.unique_short_id'
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -263,10 +261,7 @@ class CirclesRequestBuilder extends CoreRequestBuilder {
|
|||
$expr->andX(
|
||||
$expr->eq(
|
||||
'u.circle_id',
|
||||
$qb->createFunction(
|
||||
'SUBSTR(' . $pf . '`unique_id`, 1, ' . Circle::SHORT_UNIQUE_ID_LENGTH
|
||||
. ')'
|
||||
)
|
||||
$this->default_select_alias . '.unique_short_id'
|
||||
),
|
||||
$expr->eq('u.user_id', $qb->createNamedParameter($userId)),
|
||||
$expr->eq('u.user_type', $qb->createNamedParameter(Member::TYPE_USER))
|
||||
|
@ -297,11 +292,8 @@ class CirclesRequestBuilder extends CoreRequestBuilder {
|
|||
$this->default_select_alias, CoreRequestBuilder::TABLE_MEMBERS, 'o',
|
||||
$expr->andX(
|
||||
$expr->eq(
|
||||
$qb->createFunction(
|
||||
'SUBSTR(' . $pf . '`unique_id`, 1, ' . Circle::SHORT_UNIQUE_ID_LENGTH
|
||||
. ')'
|
||||
)
|
||||
, 'o.circle_id'
|
||||
$this->default_select_alias . '.unique_short_id',
|
||||
'o.circle_id'
|
||||
),
|
||||
$expr->eq('o.level', $qb->createNamedParameter(Member::LEVEL_OWNER)),
|
||||
$expr->eq('o.user_type', $qb->createNamedParameter(Member::TYPE_USER))
|
||||
|
@ -357,9 +349,7 @@ class CirclesRequestBuilder extends CoreRequestBuilder {
|
|||
->where(
|
||||
$qb->expr()
|
||||
->eq(
|
||||
$qb->createFunction(
|
||||
'SUBSTR(`unique_id`, 1, ' . Circle::SHORT_UNIQUE_ID_LENGTH . ')'
|
||||
),
|
||||
'unique_short_id',
|
||||
$qb->createNamedParameter($circleUniqueId)
|
||||
)
|
||||
);
|
||||
|
|
|
@ -149,12 +149,13 @@ class CoreRequestBuilder {
|
|||
*/
|
||||
protected function limitToShortenUniqueId(IQueryBuilder &$qb, $circleUniqueId, $length) {
|
||||
$expr = $qb->expr();
|
||||
$unqoutedPf = ($qb->getType() === QueryBuilder::SELECT) ? $this->default_select_alias . '.' : '';
|
||||
$pf = ($qb->getType() === QueryBuilder::SELECT) ? '`' . $this->default_select_alias . '`.' : '';
|
||||
|
||||
$qb->andWhere(
|
||||
$expr->eq(
|
||||
$qb->createNamedParameter($circleUniqueId),
|
||||
$qb->createFunction('SUBSTR(' . $pf . '`unique_id`' . ', 1, ' . $length . ')')
|
||||
$unqoutedPf . 'unique_short_id'
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -326,9 +327,7 @@ class CoreRequestBuilder {
|
|||
->andWhere(
|
||||
$expr->eq(
|
||||
$pf . 'circle_id',
|
||||
$qb->createFunction(
|
||||
'SUBSTR(`c`.`unique_id`, 1, ' . Circle::SHORT_UNIQUE_ID_LENGTH . ')'
|
||||
)
|
||||
'c.unique_short_id'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -356,9 +355,7 @@ class CoreRequestBuilder {
|
|||
$this->default_select_alias, CoreRequestBuilder::TABLE_CIRCLES, 'lc',
|
||||
$expr->eq(
|
||||
$pf . 'circle_id',
|
||||
$qb->createFunction(
|
||||
'SUBSTR(`lc`.`unique_id`, 1, ' . Circle::SHORT_UNIQUE_ID_LENGTH . ')'
|
||||
)
|
||||
'lc.unique_short_id'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -390,7 +387,7 @@ class CoreRequestBuilder {
|
|||
$expr->eq('ncgu.gid', 'g.group_id'),
|
||||
$expr->eq(
|
||||
'g.circle_id', $qb->createFunction(
|
||||
'SUBSTR(' . $field . ', 1, ' . Circle::SHORT_UNIQUE_ID_LENGTH . ')'
|
||||
$field
|
||||
)
|
||||
)
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue