GroupMembershipResolver: Parse filters before iterating through objects
Massive performance improvement! Up to 10x!
This commit is contained in:
parent
f6cf1a4245
commit
0b7bb123cd
|
@ -401,7 +401,7 @@ abstract class GroupMembershipResolver
|
||||||
// TODO: fix this last hard host dependency
|
// TODO: fix this last hard host dependency
|
||||||
$resolver = HostApplyMatches::prepare($object);
|
$resolver = HostApplyMatches::prepare($object);
|
||||||
foreach ($groups as $groupId => $filter) {
|
foreach ($groups as $groupId => $filter) {
|
||||||
if ($resolver->matchesFilter(Filter::fromQueryString($filter))) {
|
if ($resolver->matchesFilter($filter)) {
|
||||||
if (! array_key_exists($groupId, $mappings)) {
|
if (! array_key_exists($groupId, $mappings)) {
|
||||||
$mappings[$groupId] = array();
|
$mappings[$groupId] = array();
|
||||||
}
|
}
|
||||||
|
@ -456,7 +456,7 @@ abstract class GroupMembershipResolver
|
||||||
$list[$id] = $group->get('assign_filter');
|
$list[$id] = $group->get('assign_filter');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $list;
|
return $this->parseFilters($list);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function fetchAppliedGroups()
|
protected function fetchAppliedGroups()
|
||||||
|
@ -470,7 +470,21 @@ abstract class GroupMembershipResolver
|
||||||
)
|
)
|
||||||
)->where('assign_filter IS NOT NULL');
|
)->where('assign_filter IS NOT NULL');
|
||||||
|
|
||||||
return $this->db->fetchPairs($query);
|
return $this->parseFilters($this->db->fetchPairs($query));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parsing a list of query strings to Filter
|
||||||
|
*
|
||||||
|
* @param string[] $list List of query strings
|
||||||
|
*
|
||||||
|
* @return Filter[]
|
||||||
|
*/
|
||||||
|
protected function parseFilters($list)
|
||||||
|
{
|
||||||
|
return array_map(function ($s) {
|
||||||
|
return Filter::fromQueryString($s);
|
||||||
|
}, $list);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function fetchMissingSingleAssignments()
|
protected function fetchMissingSingleAssignments()
|
||||||
|
|
Loading…
Reference in New Issue