mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
MDL-64258 Group: Performance problem on the enrol group members page
This commit is contained in:
parent
53f796b91a
commit
afcc7a723d
@ -890,7 +890,15 @@ class group_non_members_selector extends groups_user_selector_base {
|
||||
list($searchcondition, $searchparams) = $this->search_sql($search, 'u');
|
||||
|
||||
// Build the SQL.
|
||||
list($enrolsql, $enrolparams) = get_enrolled_sql($context);
|
||||
$enrolledjoin = get_enrolled_join($context, 'u.id');
|
||||
|
||||
$wheres = [];
|
||||
$wheres[] = $enrolledjoin->wheres;
|
||||
$wheres[] = 'u.deleted = 0';
|
||||
$wheres[] = 'gm.id IS NULL';
|
||||
$wheres = implode(' AND ', $wheres);
|
||||
$wheres .= ' AND ' . $searchcondition;
|
||||
|
||||
$fields = "SELECT r.id AS roleid, u.id AS userid,
|
||||
" . $this->required_fields_sql('u') . ",
|
||||
(SELECT count(igm.groupid)
|
||||
@ -898,18 +906,16 @@ class group_non_members_selector extends groups_user_selector_base {
|
||||
JOIN {groups} ig ON igm.groupid = ig.id
|
||||
WHERE igm.userid = u.id AND ig.courseid = :courseid) AS numgroups";
|
||||
$sql = " FROM {user} u
|
||||
JOIN ($enrolsql) e ON e.id = u.id
|
||||
$enrolledjoin->joins
|
||||
LEFT JOIN {role_assignments} ra ON (ra.userid = u.id AND ra.contextid $relatedctxsql AND ra.roleid $roleids)
|
||||
LEFT JOIN {role} r ON r.id = ra.roleid
|
||||
LEFT JOIN {groups_members} gm ON (gm.userid = u.id AND gm.groupid = :groupid)
|
||||
WHERE u.deleted = 0
|
||||
AND gm.id IS NULL
|
||||
AND $searchcondition";
|
||||
WHERE $wheres";
|
||||
|
||||
list($sort, $sortparams) = users_order_by_sql('u', $search, $this->accesscontext);
|
||||
$orderby = ' ORDER BY ' . $sort;
|
||||
|
||||
$params = array_merge($searchparams, $roleparams, $enrolparams, $relatedctxparams);
|
||||
$params = array_merge($searchparams, $roleparams, $relatedctxparams, $enrolledjoin->params);
|
||||
$params['courseid'] = $this->courseid;
|
||||
$params['groupid'] = $this->groupid;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user