{"action":"created","comment":{"url":"https://api.github.com/repos/edx/edx-platform/pulls/comments/47139252","id":47139252,"diff_hunk":"@@ -362,6 +421,61 @@ def pre_requisite_courses(self):\n         return json.loads(self._pre_requisite_courses_json)\n \n     @classmethod\n+    def get_select_courses(cls, course_keys):\n+        \"\"\"\n+        Returns CourseOverview objects for the given course_keys.\n+        \"\"\"\n+        course_overviews = []\n+\n+        log.info('Generating course overview for %d courses.', len(course_keys))\n+        log.debug('Generating course overview(s) for the following courses: %s', course_keys)\n+\n+        for course_key in course_keys:\n+            try:\n+                course_overviews.append(CourseOverview.get_from_id(course_key))\n+            except Exception as ex:  # pylint: disable=broad-except\n+                log.exception(\n+                    'An error occurred while generating course overview for %s: %s',\n+                    unicode(course_key),\n+                    ex.message,\n+                )\n+\n+        log.info('Finished generating course overviews.')\n+\n+        return course_overviews\n+\n+    @classmethod\n+    def get_all_courses(cls, force_reseeding=False):\n+        \"\"\"\n+        Returns all CourseOverview objects in the database.\n+\n+        Arguments:\n+            force_reseeding (bool): Optional parameter.\n+                If True, the modulestore is used as the source of truth for\n+                the list of courses, even if the CourseOverview table was\n+                previously seeded.\n+\n+                If False, the list of courses is retrieved from the\n+                CourseOverview table if it was previously seeded, falling\n+                back to the modulestore if it wasn't seeded.\n+        \"\"\"\n+        if force_reseeding or not CourseOverviewGeneratedHistory.objects.first():\n+            # Seed the CourseOverview table with data for all\n+            # courses in the system.\n+            course_keys = [course.id for course in modulestore().get_courses()]\n+            course_overviews = cls.get_select_courses(course_keys)\n+            CourseOverviewGeneratedHistory.objects.create(num_courses=len(course_overviews))","path":"openedx/core/djangoapps/content/course_overviews/models.py","position":194,"original_position":194,"commit_id":"1ed0e9d5ea8b51b5f4b5e6b39b230ee1e857bb26","original_commit_id":"1ed0e9d5ea8b51b5f4b5e6b39b230ee1e857bb26","user":{"login":"ormsbee","id":41625,"avatar_url":"https://avatars.githubusercontent.com/u/41625?v=3","gravatar_id":"","url":"https://api.github.com/users/ormsbee","html_url":"https://github.com/ormsbee","followers_url":"https://api.github.com/users/ormsbee/followers","following_url":"https://api.github.com/users/ormsbee/following{/other_user}","gists_url":"https://api.github.com/users/ormsbee/gists{/gist_id}","starred_url":"https://api.github.com/users/ormsbee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ormsbee/subscriptions","organizations_url":"https://api.github.com/users/ormsbee/orgs","repos_url":"https://api.github.com/users/ormsbee/repos","events_url":"https://api.github.com/users/ormsbee/events{/privacy}","received_events_url":"https://api.github.com/users/ormsbee/received_events","type":"User","site_admin":false},"body":"Oh wait, I think I read that wrong. All this does is iterate through the keys, it doesn't build new CourseOverviews? ","created_at":"2015-12-09T19:29:40Z","updated_at":"2015-12-09T19:29:40Z","html_url":"https://github.com/edx/edx-platform/pull/10841#discussion_r47139252","pull_request_url":"https://api.github.com/repos/edx/edx-platform/pulls/10841","_links":{"self":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/comments/47139252"},"html":{"href":"https://github.com/edx/edx-platform/pull/10841#discussion_r47139252"},"pull_request":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/10841"}}},"pull_request":{"url":"https://api.github.com/repos/edx/edx-platform/pulls/10841","id":52742115,"html_url":"https://github.com/edx/edx-platform/pull/10841","diff_url":"https://github.com/edx/edx-platform/pull/10841.diff","patch_url":"https://github.com/edx/edx-platform/pull/10841.patch","issue_url":"https://api.github.com/repos/edx/edx-platform/issues/10841","number":10841,"state":"open","locked":false,"title":"Optimize Course Catalog using CourseOverview","user":{"login":"nasthagiri","id":6772826,"avatar_url":"https://avatars.githubusercontent.com/u/6772826?v=3","gravatar_id":"","url":"https://api.github.com/users/nasthagiri","html_url":"https://github.com/nasthagiri","followers_url":"https://api.github.com/users/nasthagiri/followers","following_url":"https://api.github.com/users/nasthagiri/following{/other_user}","gists_url":"https://api.github.com/users/nasthagiri/gists{/gist_id}","starred_url":"https://api.github.com/users/nasthagiri/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nasthagiri/subscriptions","organizations_url":"https://api.github.com/users/nasthagiri/orgs","repos_url":"https://api.github.com/users/nasthagiri/repos","events_url":"https://api.github.com/users/nasthagiri/events{/privacy}","received_events_url":"https://api.github.com/users/nasthagiri/received_events","type":"User","site_admin":false},"body":"This PR improves the performance of the Course Catalog API and the Course Catalog view for open edX instances by updating their code to retrieve information about the courses from CourseOverview data (in SQL) rather than through instantiated course modules from the modulestore (in MongoDB).\r\n\r\nThe following changes were made as part of this effort:\r\n* Added the following fields to `CourseOverview`: \r\n  * announcement\r\n  * catalog_visibility\r\n  * course_video_url\r\n  * effort\r\n  * short_description\r\n* Updated the Course index view to use CourseOverview.\r\n* Updated the Course Catalog and Course Detail APIs to use CourseOverview.\r\n  * Fixed the Course Detail API to check the correct permission.\r\n* Required the existence of CourseOverview models for each course in the system\r\n  * Introduced a `CourseOverviewGeneratedHistory` model to keep track of when the `CourseOverview` table is seeded with all courses in the system.\r\n  * Can be bootstrapped by calling the [generate_course_overview](https://github.com/edx/edx-platform/blob/master/openedx/core/djangoapps/content/course_overviews/management/commands/generate_course_overview.py) management command.\r\n  * But also now lazily computed, when needed.\r\n* Removed support for the outdated `ispublic` field on the Course Module, including its corresponding `ACCESS_REQUIRE_STAFF_FOR_COURSE` feature flag.\r\n* Removed unused function [get_course_university_about_section](https://github.com/edx/edx-platform/blob/master/lms/djangoapps/courseware/courses.py#L132).\r\n* Removed support for 'title', 'university', and 'number' from [get_course_about_section](https://github.com/edx/edx-platform/blob/master/lms/djangoapps/courseware/courses.py#L142) since they are no longer stored as course about HTML modules, and should instead be accessed directly from the Course Module.\r\n\r\n*Reviewers:* @ormsbee, @robrap \r\n*FYI:* @cahrens, @rlucioni ","created_at":"2015-12-05T01:25:33Z","updated_at":"2015-12-09T19:29:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c1598cd7d61445b1b577626b5679c3fc28be487c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/edx/edx-platform/pulls/10841/commits","review_comments_url":"https://api.github.com/repos/edx/edx-platform/pulls/10841/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/10841/comments","statuses_url":"https://api.github.com/repos/edx/edx-platform/statuses/1ed0e9d5ea8b51b5f4b5e6b39b230ee1e857bb26","head":{"label":"edx:mobile/optimize-course-api","ref":"mobile/optimize-course-api","sha":"1ed0e9d5ea8b51b5f4b5e6b39b230ee1e857bb26","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":"The Open edX platform, the software that powers edX!","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-12-09T16:41:54Z","pushed_at":"2015-12-09T19:12:04Z","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://open.edx.org/","size":630164,"stargazers_count":2290,"watchers_count":2290,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1395,"mirror_url":null,"open_issues_count":142,"forks":1395,"open_issues":142,"watchers":2290,"default_branch":"master"}},"base":{"label":"edx:master","ref":"master","sha":"a974cec3bee1cc22bbef30314210512dc48cbd0b","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":"The Open edX platform, the software that powers edX!","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-12-09T16:41:54Z","pushed_at":"2015-12-09T19:12:04Z","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://open.edx.org/","size":630164,"stargazers_count":2290,"watchers_count":2290,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1395,"mirror_url":null,"open_issues_count":142,"forks":1395,"open_issues":142,"watchers":2290,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/10841"},"html":{"href":"https://github.com/edx/edx-platform/pull/10841"},"issue":{"href":"https://api.github.com/repos/edx/edx-platform/issues/10841"},"comments":{"href":"https://api.github.com/repos/edx/edx-platform/issues/10841/comments"},"review_comments":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/10841/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/10841/commits"},"statuses":{"href":"https://api.github.com/repos/edx/edx-platform/statuses/1ed0e9d5ea8b51b5f4b5e6b39b230ee1e857bb26"}}}}