{"action":"created","comment":{"url":"https://api.github.com/repos/edx/edx-platform/pulls/comments/22894578","id":22894578,"diff_hunk":"@@ -192,17 +193,21 @@ def find_courses(self, user, access_type, values=None):\n \n     # pylint: disable=missing-docstring\n     def _get_courses_with_access_type(self, user, access_type):\n-\n         # Check the application cache and update if not present. The application\n         # cache is useful since there are calls to different endpoints in close\n-        # succession, for example the id_token and user_info endpoins.\n+        # succession, for example the id_token and user_info endpoints.\n \n         key = '-'.join([str(self.__class__), str(user.id), access_type])\n         course_ids = cache.get(key)\n \n-        if course_ids is None:\n-            course_ids = [unicode(course.id) for course in _get_all_courses()\n-                          if has_access(user, access_type, course)]\n+        if not course_ids:\n+            if GlobalStaff().has_user(user):\n+                # Global staff have access to all courses, so just return them all.\n+                course_ids = [unicode(course.id) for course in _get_all_courses()]","path":"lms/djangoapps/oauth2_handler/handlers.py","position":75,"original_position":75,"commit_id":"00d93bd257c5e4da3e2f11f1c73fe23ebf42ce10","original_commit_id":"00d93bd257c5e4da3e2f11f1c73fe23ebf42ce10","user":{"login":"rocha","id":51551,"avatar_url":"https://avatars.githubusercontent.com/u/51551?v=3","gravatar_id":"","url":"https://api.github.com/users/rocha","html_url":"https://github.com/rocha","followers_url":"https://api.github.com/users/rocha/followers","following_url":"https://api.github.com/users/rocha/following{/other_user}","gists_url":"https://api.github.com/users/rocha/gists{/gist_id}","starred_url":"https://api.github.com/users/rocha/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rocha/subscriptions","organizations_url":"https://api.github.com/users/rocha/orgs","repos_url":"https://api.github.com/users/rocha/repos","events_url":"https://api.github.com/users/rocha/events{/privacy}","received_events_url":"https://api.github.com/users/rocha/received_events","type":"User","site_admin":false},"body":"We can move the `unicode` function to `_get_all_courses`, and maybe rename it to `_get_all_course_ids`.\r\n```\r\ncourse_ids = _get_all_course_ids()\r\n```","created_at":"2015-01-13T21:06:07Z","updated_at":"2015-01-13T21:06:07Z","html_url":"https://github.com/edx/edx-platform/pull/6490#discussion_r22894578","pull_request_url":"https://api.github.com/repos/edx/edx-platform/pulls/6490","_links":{"self":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/comments/22894578"},"html":{"href":"https://github.com/edx/edx-platform/pull/6490#discussion_r22894578"},"pull_request":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/6490"}}},"pull_request":{"url":"https://api.github.com/repos/edx/edx-platform/pulls/6490","id":26992837,"html_url":"https://github.com/edx/edx-platform/pull/6490","diff_url":"https://github.com/edx/edx-platform/pull/6490.diff","patch_url":"https://github.com/edx/edx-platform/pull/6490.patch","issue_url":"https://api.github.com/repos/edx/edx-platform/issues/6490","number":6490,"state":"open","locked":false,"title":"Updated _get_courses_with_access_type","user":{"login":"clintonb","id":910510,"avatar_url":"https://avatars.githubusercontent.com/u/910510?v=3","gravatar_id":"","url":"https://api.github.com/users/clintonb","html_url":"https://github.com/clintonb","followers_url":"https://api.github.com/users/clintonb/followers","following_url":"https://api.github.com/users/clintonb/following{/other_user}","gists_url":"https://api.github.com/users/clintonb/gists{/gist_id}","starred_url":"https://api.github.com/users/clintonb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clintonb/subscriptions","organizations_url":"https://api.github.com/users/clintonb/orgs","repos_url":"https://api.github.com/users/clintonb/repos","events_url":"https://api.github.com/users/clintonb/events{/privacy}","received_events_url":"https://api.github.com/users/clintonb/received_events","type":"User","site_admin":false},"body":"- Return all courses for global staff without iteration\r\n- Use UserBasedRole to quickly determine for which courses a user has a specified role\r\n\r\nThis should help improve Insights login times and resolve timeout errors seen in the past.\r\n\r\n@rocha @mulby @cpennington ","created_at":"2015-01-07T22:24:35Z","updated_at":"2015-01-13T21:06:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ff0430a51a26cee6e6daf7c9a8e133605de759ae","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/edx/edx-platform/pulls/6490/commits","review_comments_url":"https://api.github.com/repos/edx/edx-platform/pulls/6490/comments","review_comment_url":"https://api.github.com/repos/edx/edx-platform/pulls/comments/{number}","comments_url":"https://api.github.com/repos/edx/edx-platform/issues/6490/comments","statuses_url":"https://api.github.com/repos/edx/edx-platform/statuses/00d93bd257c5e4da3e2f11f1c73fe23ebf42ce10","head":{"label":"edx:clintonb/oauth2-course-finder-improvements","ref":"clintonb/oauth2-course-finder-improvements","sha":"00d93bd257c5e4da3e2f11f1c73fe23ebf42ce10","user":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"repo":{"id":10391073,"name":"edx-platform","full_name":"edx/edx-platform","owner":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/edx/edx-platform","description":"Open edX, the edX platform that powers http://edx.org","fork":false,"url":"https://api.github.com/repos/edx/edx-platform","forks_url":"https://api.github.com/repos/edx/edx-platform/forks","keys_url":"https://api.github.com/repos/edx/edx-platform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/edx-platform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/edx-platform/teams","hooks_url":"https://api.github.com/repos/edx/edx-platform/hooks","issue_events_url":"https://api.github.com/repos/edx/edx-platform/issues/events{/number}","events_url":"https://api.github.com/repos/edx/edx-platform/events","assignees_url":"https://api.github.com/repos/edx/edx-platform/assignees{/user}","branches_url":"https://api.github.com/repos/edx/edx-platform/branches{/branch}","tags_url":"https://api.github.com/repos/edx/edx-platform/tags","blobs_url":"https://api.github.com/repos/edx/edx-platform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/edx-platform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/edx-platform/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/edx-platform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/edx-platform/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/edx-platform/languages","stargazers_url":"https://api.github.com/repos/edx/edx-platform/stargazers","contributors_url":"https://api.github.com/repos/edx/edx-platform/contributors","subscribers_url":"https://api.github.com/repos/edx/edx-platform/subscribers","subscription_url":"https://api.github.com/repos/edx/edx-platform/subscription","commits_url":"https://api.github.com/repos/edx/edx-platform/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/edx-platform/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/edx-platform/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/edx-platform/issues/comments/{number}","contents_url":"https://api.github.com/repos/edx/edx-platform/contents/{+path}","compare_url":"https://api.github.com/repos/edx/edx-platform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/edx-platform/merges","archive_url":"https://api.github.com/repos/edx/edx-platform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/edx-platform/downloads","issues_url":"https://api.github.com/repos/edx/edx-platform/issues{/number}","pulls_url":"https://api.github.com/repos/edx/edx-platform/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/edx-platform/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/edx-platform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/edx-platform/labels{/name}","releases_url":"https://api.github.com/repos/edx/edx-platform/releases{/id}","created_at":"2013-05-30T20:20:38Z","updated_at":"2015-01-13T19:20:22Z","pushed_at":"2015-01-13T21:05:46Z","git_url":"git://github.com/edx/edx-platform.git","ssh_url":"git@github.com:edx/edx-platform.git","clone_url":"https://github.com/edx/edx-platform.git","svn_url":"https://github.com/edx/edx-platform","homepage":"http://openedx.org/","size":1576799,"stargazers_count":1668,"watchers_count":1668,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":956,"mirror_url":null,"open_issues_count":144,"forks":956,"open_issues":144,"watchers":1668,"default_branch":"master"}},"base":{"label":"edx:master","ref":"master","sha":"82d02851a7d0102417d8ab96fd5472c2732adb6f","user":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"repo":{"id":10391073,"name":"edx-platform","full_name":"edx/edx-platform","owner":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/edx/edx-platform","description":"Open edX, the edX platform that powers http://edx.org","fork":false,"url":"https://api.github.com/repos/edx/edx-platform","forks_url":"https://api.github.com/repos/edx/edx-platform/forks","keys_url":"https://api.github.com/repos/edx/edx-platform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/edx-platform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/edx-platform/teams","hooks_url":"https://api.github.com/repos/edx/edx-platform/hooks","issue_events_url":"https://api.github.com/repos/edx/edx-platform/issues/events{/number}","events_url":"https://api.github.com/repos/edx/edx-platform/events","assignees_url":"https://api.github.com/repos/edx/edx-platform/assignees{/user}","branches_url":"https://api.github.com/repos/edx/edx-platform/branches{/branch}","tags_url":"https://api.github.com/repos/edx/edx-platform/tags","blobs_url":"https://api.github.com/repos/edx/edx-platform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/edx-platform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/edx-platform/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/edx-platform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/edx-platform/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/edx-platform/languages","stargazers_url":"https://api.github.com/repos/edx/edx-platform/stargazers","contributors_url":"https://api.github.com/repos/edx/edx-platform/contributors","subscribers_url":"https://api.github.com/repos/edx/edx-platform/subscribers","subscription_url":"https://api.github.com/repos/edx/edx-platform/subscription","commits_url":"https://api.github.com/repos/edx/edx-platform/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/edx-platform/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/edx-platform/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/edx-platform/issues/comments/{number}","contents_url":"https://api.github.com/repos/edx/edx-platform/contents/{+path}","compare_url":"https://api.github.com/repos/edx/edx-platform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/edx-platform/merges","archive_url":"https://api.github.com/repos/edx/edx-platform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/edx-platform/downloads","issues_url":"https://api.github.com/repos/edx/edx-platform/issues{/number}","pulls_url":"https://api.github.com/repos/edx/edx-platform/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/edx-platform/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/edx-platform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/edx-platform/labels{/name}","releases_url":"https://api.github.com/repos/edx/edx-platform/releases{/id}","created_at":"2013-05-30T20:20:38Z","updated_at":"2015-01-13T19:20:22Z","pushed_at":"2015-01-13T21:05:46Z","git_url":"git://github.com/edx/edx-platform.git","ssh_url":"git@github.com:edx/edx-platform.git","clone_url":"https://github.com/edx/edx-platform.git","svn_url":"https://github.com/edx/edx-platform","homepage":"http://openedx.org/","size":1576799,"stargazers_count":1668,"watchers_count":1668,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":956,"mirror_url":null,"open_issues_count":144,"forks":956,"open_issues":144,"watchers":1668,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/6490"},"html":{"href":"https://github.com/edx/edx-platform/pull/6490"},"issue":{"href":"https://api.github.com/repos/edx/edx-platform/issues/6490"},"comments":{"href":"https://api.github.com/repos/edx/edx-platform/issues/6490/comments"},"review_comments":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/6490/comments"},"review_comment":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/6490/commits"},"statuses":{"href":"https://api.github.com/repos/edx/edx-platform/statuses/00d93bd257c5e4da3e2f11f1c73fe23ebf42ce10"}}}}