{"action":"created","comment":{"url":"https://api.github.com/repos/edx/edx-platform/pulls/comments/32732177","id":32732177,"diff_hunk":"@@ -0,0 +1,256 @@\n+\"\"\"\n+Tests for course_overviews app.\n+\"\"\"\n+import datetime\n+import ddt\n+import itertools\n+import pytz\n+import math\n+\n+from django.utils import timezone\n+\n+from lms.djangoapps.certificates.api import get_active_web_certificate\n+from lms.djangoapps.courseware.courses import course_image_url\n+from xmodule.course_metadata_utils import DEFAULT_START_DATE\n+from xmodule.modulestore import ModuleStoreEnum\n+from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase\n+from xmodule.modulestore.tests.factories import CourseFactory, check_mongo_calls, check_mongo_calls_range\n+\n+from .models import CourseOverview\n+\n+\n+@ddt.ddt\n+class CourseOverviewTestCase(ModuleStoreTestCase):\n+    \"\"\"\n+    Tests for CourseOverviewDescriptor model.\n+    \"\"\"\n+\n+    TODAY = timezone.now()\n+    LAST_MONTH = TODAY + datetime.timedelta(days=30)","path":"openedx/core/djangoapps/content/course_overviews/tests.py","position":29,"original_position":29,"commit_id":"f0d67bf5dcf194cc42511bf29b51fea4bbffc112","original_commit_id":"f0d67bf5dcf194cc42511bf29b51fea4bbffc112","user":{"login":"mekkz","id":3628148,"avatar_url":"https://avatars.githubusercontent.com/u/3628148?v=3","gravatar_id":"","url":"https://api.github.com/users/mekkz","html_url":"https://github.com/mekkz","followers_url":"https://api.github.com/users/mekkz/followers","following_url":"https://api.github.com/users/mekkz/following{/other_user}","gists_url":"https://api.github.com/users/mekkz/gists{/gist_id}","starred_url":"https://api.github.com/users/mekkz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mekkz/subscriptions","organizations_url":"https://api.github.com/users/mekkz/orgs","repos_url":"https://api.github.com/users/mekkz/repos","events_url":"https://api.github.com/users/mekkz/events{/privacy}","received_events_url":"https://api.github.com/users/mekkz/received_events","type":"User","site_admin":false},"body":"Dur. Good catch.","created_at":"2015-06-18T14:00:00Z","updated_at":"2015-06-18T14:00:00Z","html_url":"https://github.com/edx/edx-platform/pull/8484#discussion_r32732177","pull_request_url":"https://api.github.com/repos/edx/edx-platform/pulls/8484","_links":{"self":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/comments/32732177"},"html":{"href":"https://github.com/edx/edx-platform/pull/8484#discussion_r32732177"},"pull_request":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/8484"}}},"pull_request":{"url":"https://api.github.com/repos/edx/edx-platform/pulls/8484","id":37481164,"html_url":"https://github.com/edx/edx-platform/pull/8484","diff_url":"https://github.com/edx/edx-platform/pull/8484.diff","patch_url":"https://github.com/edx/edx-platform/pull/8484.patch","issue_url":"https://api.github.com/repos/edx/edx-platform/issues/8484","number":8484,"state":"open","locked":false,"title":"Introduce caching of course metadata with app course_overviews","user":{"login":"mekkz","id":3628148,"avatar_url":"https://avatars.githubusercontent.com/u/3628148?v=3","gravatar_id":"","url":"https://api.github.com/users/mekkz","html_url":"https://github.com/mekkz","followers_url":"https://api.github.com/users/mekkz/followers","following_url":"https://api.github.com/users/mekkz/following{/other_user}","gists_url":"https://api.github.com/users/mekkz/gists{/gist_id}","starred_url":"https://api.github.com/users/mekkz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mekkz/subscriptions","organizations_url":"https://api.github.com/users/mekkz/orgs","repos_url":"https://api.github.com/users/mekkz/repos","events_url":"https://api.github.com/users/mekkz/events{/privacy}","received_events_url":"https://api.github.com/users/mekkz/received_events","type":"User","site_admin":false},"body":"**Background**\r\n\r\nThe creation of this app was spurred by the findings detailed here: https://openedx.atlassian.net/wiki/display/MA/MA-296%3A+UserCourseEnrollmentList+Performance+Investigation. \r\n\r\nIn short, the mobile UserCourseEnrollmentsList endpoint is very slow because it spends too long querying database through the modulestore. This app solves that problem by caching all the information about a course that is necessary to display that course on a \"dashboard\" in a MySQL table. We hope that this system may be useful in any scenario where one needs to retrieve basic information on a large number of courses, such as in the user dashboard or in the upcoming course metadata API.\r\n\r\n**Design**\r\n\r\nThis PR creates the app course_overviews, which exports the model CourseOverview. The model contains basic metadata about a course, such as its usage key, image URL, start/end dates, pre-requisite courses, etc. (essentially, anything required to describe a course as part of a user dashboard or enrollment API).\r\n\r\nTo create a CourseOverview, call CourseOverview.get_from_id(course_id), which works as follows:\r\n* If there is already a matching CourseOverview saved in its MySQL table:\r\n  * Load the object and return it\r\n* Else:\r\n  * Load a CourseDescriptor from modulestore\r\n  * Create a new CourseOverview object from it\r\n  * Save the object to MySQL and return it\r\n\r\nWhenever a course is published, we delete the corresponding CourseOverview (\"invalidating the cache,\" per se).\r\n\r\n**This PR...**\r\n\r\n* Creates the app\r\n* Makes use of it in the UserCourseEnrollmentsList endpoing\r\n* **Doesn't** make use of it on the LMS user dashboard (that'll be a separate PR)\r\n\r\nReviewers: @nasthagiri, @doctoryes \r\nFYI: @ormsbee @cpennington @BenjiLee \r\n","created_at":"2015-06-11T16:15:40Z","updated_at":"2015-06-18T14:00:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"92e79eafcc7df29f8ea2e986b7798a8368f453c2","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/edx/edx-platform/pulls/8484/commits","review_comments_url":"https://api.github.com/repos/edx/edx-platform/pulls/8484/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/8484/comments","statuses_url":"https://api.github.com/repos/edx/edx-platform/statuses/f0d67bf5dcf194cc42511bf29b51fea4bbffc112","head":{"label":"edx:mekkz/course-overviews","ref":"mekkz/course-overviews","sha":"f0d67bf5dcf194cc42511bf29b51fea4bbffc112","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-06-18T03:23:52Z","pushed_at":"2015-06-18T13:56: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://open.edx.org/","size":1918470,"stargazers_count":1988,"watchers_count":1988,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1142,"mirror_url":null,"open_issues_count":160,"forks":1142,"open_issues":160,"watchers":1988,"default_branch":"master"}},"base":{"label":"edx:master","ref":"master","sha":"e3d820a7a44055aa3a99657e43acbc36d9ba1ec2","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-06-18T03:23:52Z","pushed_at":"2015-06-18T13:56: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://open.edx.org/","size":1918470,"stargazers_count":1988,"watchers_count":1988,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1142,"mirror_url":null,"open_issues_count":160,"forks":1142,"open_issues":160,"watchers":1988,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/8484"},"html":{"href":"https://github.com/edx/edx-platform/pull/8484"},"issue":{"href":"https://api.github.com/repos/edx/edx-platform/issues/8484"},"comments":{"href":"https://api.github.com/repos/edx/edx-platform/issues/8484/comments"},"review_comments":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/8484/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/8484/commits"},"statuses":{"href":"https://api.github.com/repos/edx/edx-platform/statuses/f0d67bf5dcf194cc42511bf29b51fea4bbffc112"}}}}