{"action":"created","comment":{"url":"https://api.github.com/repos/dimagi/commcare-hq/pulls/comments/204834359","pull_request_review_id":139982723,"id":204834359,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwNDgzNDM1OQ==","diff_hunk":"@@ -847,20 +846,12 @@ def email_report(request, domain, report_slug, report_type=ProjectReportDispatch\n         notes=form.cleaned_data['notes'], once=once\n     )[0]\n \n+    recipient_emails = set(form.cleaned_data['recipient_emails'])\n     if form.cleaned_data['send_to_owner']:\n-        email = request.couch_user.get_email()\n-        body = render_full_report_notification(request, content).content\n-\n-        send_html_email_async.delay(\n-            subject, email, body,\n-            email_from=settings.DEFAULT_FROM_EMAIL)\n-\n-    if form.cleaned_data['recipient_emails']:\n-        for recipient in form.cleaned_data['recipient_emails']:\n-            body = render_full_report_notification(request, content).content\n-            send_html_email_async.delay(\n-                subject, recipient, body,\n-                email_from=settings.DEFAULT_FROM_EMAIL)\n+        recipient_emails.add(request.couch_user.get_email())\n+\n+    for recipient in recipient_emails:","path":"corehq/apps/reports/views.py","position":38,"original_position":38,"commit_id":"303e65cae9fbdbbc9921c58ccf9d86c2f2338ab1","original_commit_id":"303e65cae9fbdbbc9921c58ccf9d86c2f2338ab1","user":{"login":"calellowitz","id":6844721,"node_id":"MDQ6VXNlcjY4NDQ3MjE=","avatar_url":"https://avatars3.githubusercontent.com/u/6844721?v=4","gravatar_id":"","url":"https://api.github.com/users/calellowitz","html_url":"https://github.com/calellowitz","followers_url":"https://api.github.com/users/calellowitz/followers","following_url":"https://api.github.com/users/calellowitz/following{/other_user}","gists_url":"https://api.github.com/users/calellowitz/gists{/gist_id}","starred_url":"https://api.github.com/users/calellowitz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/calellowitz/subscriptions","organizations_url":"https://api.github.com/users/calellowitz/orgs","repos_url":"https://api.github.com/users/calellowitz/repos","events_url":"https://api.github.com/users/calellowitz/events{/privacy}","received_events_url":"https://api.github.com/users/calellowitz/received_events","type":"User","site_admin":false},"body":"This creates a new task for each recipient which in the worst case, will attempt to send the report, then render the report as an excel file, then send the email again. If there are a lot of recipients and a large report, this could easily clog the main queue by occupying all the workers, and it repeats a lot of effort. It may be better to pass all recipients at once to `send_email_report`, and then if any of them are too large, send the rest as download links. It would be even better if you modified `export_all_rows_task` to take a list of recipients so that it could render the report once, and then send the rest of the emails. That way you could avoid replicating work, and this whole task would be executed as a single task by one worker instead of spread across all of them","created_at":"2018-07-24T16:58:43Z","updated_at":"2018-07-24T17:01:46Z","html_url":"https://github.com/dimagi/commcare-hq/pull/21280#discussion_r204834359","pull_request_url":"https://api.github.com/repos/dimagi/commcare-hq/pulls/21280","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/dimagi/commcare-hq/pulls/comments/204834359"},"html":{"href":"https://github.com/dimagi/commcare-hq/pull/21280#discussion_r204834359"},"pull_request":{"href":"https://api.github.com/repos/dimagi/commcare-hq/pulls/21280"}}},"pull_request":{"url":"https://api.github.com/repos/dimagi/commcare-hq/pulls/21280","id":203049532,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAzMDQ5NTMy","html_url":"https://github.com/dimagi/commcare-hq/pull/21280","diff_url":"https://github.com/dimagi/commcare-hq/pull/21280.diff","patch_url":"https://github.com/dimagi/commcare-hq/pull/21280.patch","issue_url":"https://api.github.com/repos/dimagi/commcare-hq/issues/21280","number":21280,"state":"open","locked":false,"title":"Rn send report link","user":{"login":"Rohit25negi","id":21310920,"node_id":"MDQ6VXNlcjIxMzEwOTIw","avatar_url":"https://avatars3.githubusercontent.com/u/21310920?v=4","gravatar_id":"","url":"https://api.github.com/users/Rohit25negi","html_url":"https://github.com/Rohit25negi","followers_url":"https://api.github.com/users/Rohit25negi/followers","following_url":"https://api.github.com/users/Rohit25negi/following{/other_user}","gists_url":"https://api.github.com/users/Rohit25negi/gists{/gist_id}","starred_url":"https://api.github.com/users/Rohit25negi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Rohit25negi/subscriptions","organizations_url":"https://api.github.com/users/Rohit25negi/orgs","repos_url":"https://api.github.com/users/Rohit25negi/repos","events_url":"https://api.github.com/users/Rohit25negi/events{/privacy}","received_events_url":"https://api.github.com/users/Rohit25negi/received_events","type":"User","site_admin":false},"body":"change contains the code to send the download link in the email when the size of the report becomes very large and rejected by the smtp server.\r\n\r\nTicket url: https://manage.dimagi.com/default.asp?264698","created_at":"2018-07-22T10:01:35Z","updated_at":"2018-07-24T17:01:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f306b5fe2a34e06c813e17318d297b669460d2a5","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":724784918,"node_id":"MDU6TGFiZWw3MjQ3ODQ5MTg=","url":"https://api.github.com/repos/dimagi/commcare-hq/labels/product/all-users-all-environments","name":"product/all-users-all-environments","color":"0e8a16","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/dimagi/commcare-hq/pulls/21280/commits","review_comments_url":"https://api.github.com/repos/dimagi/commcare-hq/pulls/21280/comments","review_comment_url":"https://api.github.com/repos/dimagi/commcare-hq/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dimagi/commcare-hq/issues/21280/comments","statuses_url":"https://api.github.com/repos/dimagi/commcare-hq/statuses/303e65cae9fbdbbc9921c58ccf9d86c2f2338ab1","head":{"label":"dimagi:rn_send_report_link","ref":"rn_send_report_link","sha":"303e65cae9fbdbbc9921c58ccf9d86c2f2338ab1","user":{"login":"dimagi","id":94514,"node_id":"MDEyOk9yZ2FuaXphdGlvbjk0NTE0","avatar_url":"https://avatars1.githubusercontent.com/u/94514?v=4","gravatar_id":"","url":"https://api.github.com/users/dimagi","html_url":"https://github.com/dimagi","followers_url":"https://api.github.com/users/dimagi/followers","following_url":"https://api.github.com/users/dimagi/following{/other_user}","gists_url":"https://api.github.com/users/dimagi/gists{/gist_id}","starred_url":"https://api.github.com/users/dimagi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dimagi/subscriptions","organizations_url":"https://api.github.com/users/dimagi/orgs","repos_url":"https://api.github.com/users/dimagi/repos","events_url":"https://api.github.com/users/dimagi/events{/privacy}","received_events_url":"https://api.github.com/users/dimagi/received_events","type":"Organization","site_admin":false},"repo":{"id":247278,"node_id":"MDEwOlJlcG9zaXRvcnkyNDcyNzg=","name":"commcare-hq","full_name":"dimagi/commcare-hq","owner":{"login":"dimagi","id":94514,"node_id":"MDEyOk9yZ2FuaXphdGlvbjk0NTE0","avatar_url":"https://avatars1.githubusercontent.com/u/94514?v=4","gravatar_id":"","url":"https://api.github.com/users/dimagi","html_url":"https://github.com/dimagi","followers_url":"https://api.github.com/users/dimagi/followers","following_url":"https://api.github.com/users/dimagi/following{/other_user}","gists_url":"https://api.github.com/users/dimagi/gists{/gist_id}","starred_url":"https://api.github.com/users/dimagi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dimagi/subscriptions","organizations_url":"https://api.github.com/users/dimagi/orgs","repos_url":"https://api.github.com/users/dimagi/repos","events_url":"https://api.github.com/users/dimagi/events{/privacy}","received_events_url":"https://api.github.com/users/dimagi/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dimagi/commcare-hq","description":"A server-side tool to help manage community health workers, written in Django","fork":false,"url":"https://api.github.com/repos/dimagi/commcare-hq","forks_url":"https://api.github.com/repos/dimagi/commcare-hq/forks","keys_url":"https://api.github.com/repos/dimagi/commcare-hq/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dimagi/commcare-hq/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dimagi/commcare-hq/teams","hooks_url":"https://api.github.com/repos/dimagi/commcare-hq/hooks","issue_events_url":"https://api.github.com/repos/dimagi/commcare-hq/issues/events{/number}","events_url":"https://api.github.com/repos/dimagi/commcare-hq/events","assignees_url":"https://api.github.com/repos/dimagi/commcare-hq/assignees{/user}","branches_url":"https://api.github.com/repos/dimagi/commcare-hq/branches{/branch}","tags_url":"https://api.github.com/repos/dimagi/commcare-hq/tags","blobs_url":"https://api.github.com/repos/dimagi/commcare-hq/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dimagi/commcare-hq/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dimagi/commcare-hq/git/refs{/sha}","trees_url":"https://api.github.com/repos/dimagi/commcare-hq/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dimagi/commcare-hq/statuses/{sha}","languages_url":"https://api.github.com/repos/dimagi/commcare-hq/languages","stargazers_url":"https://api.github.com/repos/dimagi/commcare-hq/stargazers","contributors_url":"https://api.github.com/repos/dimagi/commcare-hq/contributors","subscribers_url":"https://api.github.com/repos/dimagi/commcare-hq/subscribers","subscription_url":"https://api.github.com/repos/dimagi/commcare-hq/subscription","commits_url":"https://api.github.com/repos/dimagi/commcare-hq/commits{/sha}","git_commits_url":"https://api.github.com/repos/dimagi/commcare-hq/git/commits{/sha}","comments_url":"https://api.github.com/repos/dimagi/commcare-hq/comments{/number}","issue_comment_url":"https://api.github.com/repos/dimagi/commcare-hq/issues/comments{/number}","contents_url":"https://api.github.com/repos/dimagi/commcare-hq/contents/{+path}","compare_url":"https://api.github.com/repos/dimagi/commcare-hq/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dimagi/commcare-hq/merges","archive_url":"https://api.github.com/repos/dimagi/commcare-hq/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dimagi/commcare-hq/downloads","issues_url":"https://api.github.com/repos/dimagi/commcare-hq/issues{/number}","pulls_url":"https://api.github.com/repos/dimagi/commcare-hq/pulls{/number}","milestones_url":"https://api.github.com/repos/dimagi/commcare-hq/milestones{/number}","notifications_url":"https://api.github.com/repos/dimagi/commcare-hq/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dimagi/commcare-hq/labels{/name}","releases_url":"https://api.github.com/repos/dimagi/commcare-hq/releases{/id}","deployments_url":"https://api.github.com/repos/dimagi/commcare-hq/deployments","created_at":"2009-07-09T17:00:07Z","updated_at":"2018-07-24T14:29:43Z","pushed_at":"2018-07-24T16:11:18Z","git_url":"git://github.com/dimagi/commcare-hq.git","ssh_url":"git@github.com:dimagi/commcare-hq.git","clone_url":"https://github.com/dimagi/commcare-hq.git","svn_url":"https://github.com/dimagi/commcare-hq","homepage":"https://www.commcarehq.org","size":449429,"stargazers_count":95,"watchers_count":95,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":106,"mirror_url":null,"archived":false,"open_issues_count":88,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":106,"open_issues":88,"watchers":95,"default_branch":"master"}},"base":{"label":"dimagi:master","ref":"master","sha":"015c204852d7b745389ebfd81ba63852b6d2b17b","user":{"login":"dimagi","id":94514,"node_id":"MDEyOk9yZ2FuaXphdGlvbjk0NTE0","avatar_url":"https://avatars1.githubusercontent.com/u/94514?v=4","gravatar_id":"","url":"https://api.github.com/users/dimagi","html_url":"https://github.com/dimagi","followers_url":"https://api.github.com/users/dimagi/followers","following_url":"https://api.github.com/users/dimagi/following{/other_user}","gists_url":"https://api.github.com/users/dimagi/gists{/gist_id}","starred_url":"https://api.github.com/users/dimagi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dimagi/subscriptions","organizations_url":"https://api.github.com/users/dimagi/orgs","repos_url":"https://api.github.com/users/dimagi/repos","events_url":"https://api.github.com/users/dimagi/events{/privacy}","received_events_url":"https://api.github.com/users/dimagi/received_events","type":"Organization","site_admin":false},"repo":{"id":247278,"node_id":"MDEwOlJlcG9zaXRvcnkyNDcyNzg=","name":"commcare-hq","full_name":"dimagi/commcare-hq","owner":{"login":"dimagi","id":94514,"node_id":"MDEyOk9yZ2FuaXphdGlvbjk0NTE0","avatar_url":"https://avatars1.githubusercontent.com/u/94514?v=4","gravatar_id":"","url":"https://api.github.com/users/dimagi","html_url":"https://github.com/dimagi","followers_url":"https://api.github.com/users/dimagi/followers","following_url":"https://api.github.com/users/dimagi/following{/other_user}","gists_url":"https://api.github.com/users/dimagi/gists{/gist_id}","starred_url":"https://api.github.com/users/dimagi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dimagi/subscriptions","organizations_url":"https://api.github.com/users/dimagi/orgs","repos_url":"https://api.github.com/users/dimagi/repos","events_url":"https://api.github.com/users/dimagi/events{/privacy}","received_events_url":"https://api.github.com/users/dimagi/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dimagi/commcare-hq","description":"A server-side tool to help manage community health workers, written in Django","fork":false,"url":"https://api.github.com/repos/dimagi/commcare-hq","forks_url":"https://api.github.com/repos/dimagi/commcare-hq/forks","keys_url":"https://api.github.com/repos/dimagi/commcare-hq/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dimagi/commcare-hq/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dimagi/commcare-hq/teams","hooks_url":"https://api.github.com/repos/dimagi/commcare-hq/hooks","issue_events_url":"https://api.github.com/repos/dimagi/commcare-hq/issues/events{/number}","events_url":"https://api.github.com/repos/dimagi/commcare-hq/events","assignees_url":"https://api.github.com/repos/dimagi/commcare-hq/assignees{/user}","branches_url":"https://api.github.com/repos/dimagi/commcare-hq/branches{/branch}","tags_url":"https://api.github.com/repos/dimagi/commcare-hq/tags","blobs_url":"https://api.github.com/repos/dimagi/commcare-hq/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dimagi/commcare-hq/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dimagi/commcare-hq/git/refs{/sha}","trees_url":"https://api.github.com/repos/dimagi/commcare-hq/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dimagi/commcare-hq/statuses/{sha}","languages_url":"https://api.github.com/repos/dimagi/commcare-hq/languages","stargazers_url":"https://api.github.com/repos/dimagi/commcare-hq/stargazers","contributors_url":"https://api.github.com/repos/dimagi/commcare-hq/contributors","subscribers_url":"https://api.github.com/repos/dimagi/commcare-hq/subscribers","subscription_url":"https://api.github.com/repos/dimagi/commcare-hq/subscription","commits_url":"https://api.github.com/repos/dimagi/commcare-hq/commits{/sha}","git_commits_url":"https://api.github.com/repos/dimagi/commcare-hq/git/commits{/sha}","comments_url":"https://api.github.com/repos/dimagi/commcare-hq/comments{/number}","issue_comment_url":"https://api.github.com/repos/dimagi/commcare-hq/issues/comments{/number}","contents_url":"https://api.github.com/repos/dimagi/commcare-hq/contents/{+path}","compare_url":"https://api.github.com/repos/dimagi/commcare-hq/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dimagi/commcare-hq/merges","archive_url":"https://api.github.com/repos/dimagi/commcare-hq/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dimagi/commcare-hq/downloads","issues_url":"https://api.github.com/repos/dimagi/commcare-hq/issues{/number}","pulls_url":"https://api.github.com/repos/dimagi/commcare-hq/pulls{/number}","milestones_url":"https://api.github.com/repos/dimagi/commcare-hq/milestones{/number}","notifications_url":"https://api.github.com/repos/dimagi/commcare-hq/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dimagi/commcare-hq/labels{/name}","releases_url":"https://api.github.com/repos/dimagi/commcare-hq/releases{/id}","deployments_url":"https://api.github.com/repos/dimagi/commcare-hq/deployments","created_at":"2009-07-09T17:00:07Z","updated_at":"2018-07-24T14:29:43Z","pushed_at":"2018-07-24T16:11:18Z","git_url":"git://github.com/dimagi/commcare-hq.git","ssh_url":"git@github.com:dimagi/commcare-hq.git","clone_url":"https://github.com/dimagi/commcare-hq.git","svn_url":"https://github.com/dimagi/commcare-hq","homepage":"https://www.commcarehq.org","size":449429,"stargazers_count":95,"watchers_count":95,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":106,"mirror_url":null,"archived":false,"open_issues_count":88,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":106,"open_issues":88,"watchers":95,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dimagi/commcare-hq/pulls/21280"},"html":{"href":"https://github.com/dimagi/commcare-hq/pull/21280"},"issue":{"href":"https://api.github.com/repos/dimagi/commcare-hq/issues/21280"},"comments":{"href":"https://api.github.com/repos/dimagi/commcare-hq/issues/21280/comments"},"review_comments":{"href":"https://api.github.com/repos/dimagi/commcare-hq/pulls/21280/comments"},"review_comment":{"href":"https://api.github.com/repos/dimagi/commcare-hq/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dimagi/commcare-hq/pulls/21280/commits"},"statuses":{"href":"https://api.github.com/repos/dimagi/commcare-hq/statuses/303e65cae9fbdbbc9921c58ccf9d86c2f2338ab1"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"calellowitz"}}