{"action":"created","comment":{"url":"https://api.github.com/repos/edx/edx-platform/pulls/comments/78748410","id":78748410,"diff_hunk":"@@ -135,29 +94,40 @@ def load_from_data(self, model, course_structure, scores_client, submissions_sco\n             section=self.display_name,\n             module_id=self.location,\n         )\n+        self._log_event(log.warning, u\"init_from_model\", user)\n \n-    def __unicode__(self):\n+    @classmethod\n+    def bulk_create_models(cls, student, subsection_grades, course_key):\n         \"\"\"\n-        Provides a unicode representation of the scoring\n-        data for this subsection. Used for logging.\n+        Saves the subsection grade in a persisted model.\n         \"\"\"\n-        return u\"SubsectionGrade|total: {0}/{1}|graded: {2}/{3}|location: {4}|display name: {5}\".format(\n-            self.all_total.earned,\n-            self.all_total.possible,\n-            self.graded_total.earned,\n-            self.graded_total.possible,\n-            self.location,\n-            self.display_name\n+        return PersistentSubsectionGrade.bulk_create_grades(\n+            [subsection_grade._persisted_model_params(student) for subsection_grade in subsection_grades],  # pylint: disable=protected-access\n+            course_key,\n         )\n \n+    def create_model(self, student):\n+        \"\"\"\n+        Saves the subsection grade in a persisted model.\n+        \"\"\"\n+        self._log_event(log.info, u\"create_model\", student)\n+        return PersistentSubsectionGrade.create_grade(**self._persisted_model_params(student))\n+\n+    def update_or_create_model(self, student):\n+        \"\"\"\n+        Saves or updates the subsection grade in a persisted model.\n+        \"\"\"\n+        self._log_event(log.info, u\"update_or_create_model\", student)","path":"lms/djangoapps/grades/new/subsection_grade.py","position":124,"original_position":137,"commit_id":"9a78592d9fe0f53b0119caeeaa893a539de6bc24","original_commit_id":"06dad4a6575c678c61265e439b45c2f415b6c602","user":{"login":"sanfordstudent","id":12545624,"avatar_url":"https://avatars.githubusercontent.com/u/12545624?v=3","gravatar_id":"","url":"https://api.github.com/users/sanfordstudent","html_url":"https://github.com/sanfordstudent","followers_url":"https://api.github.com/users/sanfordstudent/followers","following_url":"https://api.github.com/users/sanfordstudent/following{/other_user}","gists_url":"https://api.github.com/users/sanfordstudent/gists{/gist_id}","starred_url":"https://api.github.com/users/sanfordstudent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sanfordstudent/subscriptions","organizations_url":"https://api.github.com/users/sanfordstudent/orgs","repos_url":"https://api.github.com/users/sanfordstudent/repos","events_url":"https://api.github.com/users/sanfordstudent/events{/privacy}","received_events_url":"https://api.github.com/users/sanfordstudent/received_events","type":"User","site_admin":false},"body":"This doesn't need to be unicode-d because it happens automatically when using `.format` with a unicode string.","created_at":"2016-09-14T13:34:08Z","updated_at":"2016-09-14T13:34:08Z","html_url":"https://github.com/edx/edx-platform/pull/13440#discussion_r78748410","pull_request_url":"https://api.github.com/repos/edx/edx-platform/pulls/13440","_links":{"self":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/comments/78748410"},"html":{"href":"https://github.com/edx/edx-platform/pull/13440#discussion_r78748410"},"pull_request":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/13440"}}},"pull_request":{"url":"https://api.github.com/repos/edx/edx-platform/pulls/13440","id":84732739,"html_url":"https://github.com/edx/edx-platform/pull/13440","diff_url":"https://github.com/edx/edx-platform/pull/13440.diff","patch_url":"https://github.com/edx/edx-platform/pull/13440.patch","issue_url":"https://api.github.com/repos/edx/edx-platform/issues/13440","number":13440,"state":"open","locked":false,"title":"Reduce sql queries on Progress Page with saved grades","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":"@jcdyer\r\n","created_at":"2016-09-09T23:09:00Z","updated_at":"2016-09-14T13:34:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"49ddf08f06d2759739c575798d80865460974808","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/edx/edx-platform/pulls/13440/commits","review_comments_url":"https://api.github.com/repos/edx/edx-platform/pulls/13440/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/13440/comments","statuses_url":"https://api.github.com/repos/edx/edx-platform/statuses/9a78592d9fe0f53b0119caeeaa893a539de6bc24","head":{"label":"edx:tnl/progress-page-queries","ref":"tnl/progress-page-queries","sha":"9a78592d9fe0f53b0119caeeaa893a539de6bc24","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}","deployments_url":"https://api.github.com/repos/edx/edx-platform/deployments","created_at":"2013-05-30T20:20:38Z","updated_at":"2016-09-13T17:27:31Z","pushed_at":"2016-09-14T13:25:35Z","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":823396,"stargazers_count":2766,"watchers_count":2766,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1659,"mirror_url":null,"open_issues_count":138,"forks":1659,"open_issues":138,"watchers":2766,"default_branch":"master"}},"base":{"label":"edx:master","ref":"master","sha":"6fd8452d24d97cbe65c18dda13dc8deba9282650","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}","deployments_url":"https://api.github.com/repos/edx/edx-platform/deployments","created_at":"2013-05-30T20:20:38Z","updated_at":"2016-09-13T17:27:31Z","pushed_at":"2016-09-14T13:25:35Z","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":823396,"stargazers_count":2766,"watchers_count":2766,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1659,"mirror_url":null,"open_issues_count":138,"forks":1659,"open_issues":138,"watchers":2766,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/13440"},"html":{"href":"https://github.com/edx/edx-platform/pull/13440"},"issue":{"href":"https://api.github.com/repos/edx/edx-platform/issues/13440"},"comments":{"href":"https://api.github.com/repos/edx/edx-platform/issues/13440/comments"},"review_comments":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/13440/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/13440/commits"},"statuses":{"href":"https://api.github.com/repos/edx/edx-platform/statuses/9a78592d9fe0f53b0119caeeaa893a539de6bc24"}}}}
{"actor":{"display_login":"sanfordstudent"}}