MDL-63785 repository_onedrive: performance improvement

This commit is contained in:
Shamim Rezaie 2018-10-27 01:48:22 +11:00
parent 6b20a81cb4
commit 45e6809b1f

View File

@ -111,21 +111,15 @@ class provider implements
public static function get_users_in_context(userlist $userlist) {
$context = $userlist->get_context();
if (!is_a($context, \context_user::class)) {
if (!$context instanceof \context_user) {
return;
}
// The data is associated at the user context level, so retrieve the user's context id.
$sql = "SELECT roa.usermodified AS userid
FROM {repository_onedrive_access} roa
JOIN {context} c ON c.instanceid = roa.usermodified AND c.contextlevel = :contextuser
WHERE c.id = :contextid";
$params = [
'contextuser' => CONTEXT_USER,
'contextid' => $context->id,
];
$sql = "SELECT usermodified AS userid
FROM {repository_onedrive_access}
WHERE usermodified = ?";
$params = [$context->instanceid];
$userlist->add_from_sql('userid', $sql, $params);
}