Skip to content

Commit

Permalink
perf(activity): improved performance of group river filter
Browse files Browse the repository at this point in the history
  • Loading branch information
jeabakker committed Dec 7, 2018
1 parent 6b05f2c commit dbfdbd6
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions mod/activity/classes/Elgg/Activity/GroupRiverFilter.php
Expand Up @@ -36,11 +36,13 @@ public function __invoke(QueryBuilder $qb, $main_alias) {
$wheres[] = $qb->compare("{$main_alias}.object_guid", '=', $this->group->guid, ELGG_VALUE_GUID);
$wheres[] = $qb->compare("{$main_alias}.target_guid", '=', $this->group->guid, ELGG_VALUE_GUID);

$object = $qb->joinEntitiesTable($main_alias, 'object_guid');
$wheres[] = $qb->compare("{$object}.container_guid", '=', $this->group->guid, ELGG_VALUE_GUID);
$sub = $qb->subquery('entities', 'ce');
$sub->select('ce.guid')
->where($qb->compare('ce.container_guid', 'in', $this->group->guid, ELGG_VALUE_GUID));

$target = $qb->joinEntitiesTable($main_alias, 'target_guid', 'left');
$wheres[] = $qb->compare("{$target}.container_guid", '=', $this->group->guid, ELGG_VALUE_GUID);
$wheres[] = $qb->compare("{$main_alias}.object_guid", 'in', $sub->getSQL());

$wheres[] = $qb->compare("{$main_alias}.target_guid", 'in', $sub->getSQL());

return $qb->merge($wheres, 'OR');
}
Expand Down

0 comments on commit dbfdbd6

Please sign in to comment.