{"action":"created","comment":{"url":"https://api.github.com/repos/edx/edx-platform/pulls/comments/27831724","id":27831724,"diff_hunk":"@@ -30,54 +30,45 @@ def setUp(self):\n             display_name='test_course'\n         )\n \n-        # Mimic monkeypatching done in startup.py\n-        Ks.KEYWORD_FUNCTION_MAP = self.get_keyword_function_map()\n-\n-    def get_keyword_function_map(self):\n-        \"\"\"\n-        Generates a mapping from keywords to functions for testing\n-\n-        The keyword sub functions should not return %% encoded strings. This\n-        would lead to ugly and inconsistent behavior due to the way in which\n-        keyword subbing is handled.\n-        \"\"\"\n-\n-        def user_fullname_sub(user, course):  # pylint: disable=unused-argument\n-            \"\"\" Returns the user's name \"\"\"\n-            return user.profile.name\n-\n-        def course_display_name_sub(user, course):  # pylint: disable=unused-argument\n-            \"\"\" Returns the course name \"\"\"\n-            return course.display_name\n-\n-        return {\n-            '%%USER_FULLNAME%%': user_fullname_sub,\n-            '%%COURSE_DISPLAY_NAME%%': course_display_name_sub,\n+        self.context = {\n+            'user_id': self.user.id,\n+            'course_title': self.course.display_name,\n+            'name': self.user.profile.name,\n+            'course_end_date': get_default_time_display(self.course.end),\n         }\n \n     @file_data('fixtures/test_keyword_coursename_sub.json')\n     def test_course_name_sub(self, test_info):\n         \"\"\" Tests subbing course name in various scenarios \"\"\"\n         course_name = self.course.display_name\n-        result = Ks.substitute_keywords_with_data(test_info['test_string'], self.user.id, self.course.id)\n+        result = Ks.substitute_keywords_with_data(\n+            test_info['test_string'], self.context","path":"common/djangoapps/util/tests/test_keyword_sub_utils.py","position":40,"original_position":40,"commit_id":"38dbc2cff966bb683704e34cb905042d5df44c78","original_commit_id":"38dbc2cff966bb683704e34cb905042d5df44c78","user":{"login":"kluo","id":868615,"avatar_url":"https://avatars.githubusercontent.com/u/868615?v=3","gravatar_id":"","url":"https://api.github.com/users/kluo","html_url":"https://github.com/kluo","followers_url":"https://api.github.com/users/kluo/followers","following_url":"https://api.github.com/users/kluo/following{/other_user}","gists_url":"https://api.github.com/users/kluo/gists{/gist_id}","starred_url":"https://api.github.com/users/kluo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kluo/subscriptions","organizations_url":"https://api.github.com/users/kluo/orgs","repos_url":"https://api.github.com/users/kluo/repos","events_url":"https://api.github.com/users/kluo/events{/privacy}","received_events_url":"https://api.github.com/users/kluo/received_events","type":"User","site_admin":false},"body":"Add trailing comma","created_at":"2015-04-06T21:20:58Z","updated_at":"2015-04-06T21:20:58Z","html_url":"https://github.com/edx/edx-platform/pull/7605#discussion_r27831724","pull_request_url":"https://api.github.com/repos/edx/edx-platform/pulls/7605","_links":{"self":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/comments/27831724"},"html":{"href":"https://github.com/edx/edx-platform/pull/7605#discussion_r27831724"},"pull_request":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/7605"}}},"pull_request":{"url":"https://api.github.com/repos/edx/edx-platform/pulls/7605","id":32683566,"html_url":"https://github.com/edx/edx-platform/pull/7605","diff_url":"https://github.com/edx/edx-platform/pull/7605.diff","patch_url":"https://github.com/edx/edx-platform/pull/7605.patch","issue_url":"https://api.github.com/repos/edx/edx-platform/issues/7605","number":7605,"state":"open","locked":false,"title":"use email context for keyword substitution, cutting down on db queries (...","user":{"login":"adampalay","id":2748698,"avatar_url":"https://avatars.githubusercontent.com/u/2748698?v=3","gravatar_id":"","url":"https://api.github.com/users/adampalay","html_url":"https://github.com/adampalay","followers_url":"https://api.github.com/users/adampalay/followers","following_url":"https://api.github.com/users/adampalay/following{/other_user}","gists_url":"https://api.github.com/users/adampalay/gists{/gist_id}","starred_url":"https://api.github.com/users/adampalay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adampalay/subscriptions","organizations_url":"https://api.github.com/users/adampalay/orgs","repos_url":"https://api.github.com/users/adampalay/repos","events_url":"https://api.github.com/users/adampalay/events{/privacy}","received_events_url":"https://api.github.com/users/adampalay/received_events","type":"User","site_admin":false},"body":"...TNL-1591)\r\n\r\n@brianhw \r\n@sarina \r\n(@feanil FYI)\r\n\r\nThe `keyword_substitution` util was causing bulk emails to make mongo and mysql calls to the db for every request, significantly slowing down sending out bulk emails. For a reference, I ran [this test](https://github.com/edx/edx-platform/blob/master/lms/djangoapps/bulk_email/tests/test_email.py#L183) on this branch and on master [with 1000 students instead of 10](https://github.com/edx/edx-platform/blob/master/lms/djangoapps/bulk_email/tests/test_email.py#L26). Here were the results:\r\n\r\nmaster: ~13.6 s (~15.3 seconds when the message contains `%%USER_ID%%`\\*)\r\nthis branch:  ~4.3s ( ~7.4 seconds when the message contains `%%USER_ID%%`\\*)\r\n\r\n*looking up the anonymous user_id requires a couple db queries, unfortunately\r\n\r\nHere is the commit that this functionality was introduced in: https://github.com/edx/edx-platform/commit/32bbb0e71a8644d4e73f11ae717897a279730ada. @caesar2164, can someone at Stanford take a look at this?","created_at":"2015-04-06T14:57:22Z","updated_at":"2015-04-06T21:20:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"795c40e3ca6c5d4d7b648a6a06c3c5fa75527a6c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/edx/edx-platform/pulls/7605/commits","review_comments_url":"https://api.github.com/repos/edx/edx-platform/pulls/7605/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/7605/comments","statuses_url":"https://api.github.com/repos/edx/edx-platform/statuses/38dbc2cff966bb683704e34cb905042d5df44c78","head":{"label":"edx:adam/bulk-email-changes","ref":"adam/bulk-email-changes","sha":"38dbc2cff966bb683704e34cb905042d5df44c78","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-04-06T20:16:40Z","pushed_at":"2015-04-06T21:07:55Z","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":1875483,"stargazers_count":1850,"watchers_count":1850,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1042,"mirror_url":null,"open_issues_count":151,"forks":1042,"open_issues":151,"watchers":1850,"default_branch":"master"}},"base":{"label":"edx:master","ref":"master","sha":"aca60546393f9d3141f7b028c8a216b41d4ea14d","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-04-06T20:16:40Z","pushed_at":"2015-04-06T21:07:55Z","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":1875483,"stargazers_count":1850,"watchers_count":1850,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1042,"mirror_url":null,"open_issues_count":151,"forks":1042,"open_issues":151,"watchers":1850,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/7605"},"html":{"href":"https://github.com/edx/edx-platform/pull/7605"},"issue":{"href":"https://api.github.com/repos/edx/edx-platform/issues/7605"},"comments":{"href":"https://api.github.com/repos/edx/edx-platform/issues/7605/comments"},"review_comments":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/7605/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/7605/commits"},"statuses":{"href":"https://api.github.com/repos/edx/edx-platform/statuses/38dbc2cff966bb683704e34cb905042d5df44c78"}}}}