{"action":"created","comment":{"url":"https://api.github.com/repos/mitodl/lore/pulls/comments/35328507","id":35328507,"diff_hunk":"@@ -3,11 +3,55 @@\n \"\"\"\n from __future__ import unicode_literals\n \n+import logging\n+\n+from django.conf import settings\n+\n from lore.celery import async\n-from importer.api import import_course_from_file\n+from learningresources.api import update_xanalytics\n+from xanalytics import send_request, get_result, get_xanalytics_file\n+\n+log = logging.getLogger(__name__)\n \n \n @async.task\n def import_file(path, repo_id, user_id):\n     \"\"\"Asynchronously import a course.\"\"\"\n+    from importer.api import import_course_from_file\n     import_course_from_file(path, repo_id, user_id)\n+\n+\n+@async.task\n+def populate_xanalytics_fields(course_id):\n+    \"\"\"\n+    Initiate request to xanalytics API to get stats for a course,\n+    then trigger async job to retrieve results when they become available.\n+    Args:\n+        course_id (int): primary key of a Course\n+    \"\"\"\n+    if settings.XANALYTICS_URL != \"\":\n+        token = send_request(settings.XANALYTICS_URL + \"/create\", course_id)","path":"importer/tasks.py","position":32,"original_position":32,"commit_id":"d92eb3f52d5a5a13f1097739ca82212e1f636327","original_commit_id":"d92eb3f52d5a5a13f1097739ca82212e1f636327","user":{"login":"ShawnMilo","id":130120,"avatar_url":"https://avatars.githubusercontent.com/u/130120?v=3","gravatar_id":"","url":"https://api.github.com/users/ShawnMilo","html_url":"https://github.com/ShawnMilo","followers_url":"https://api.github.com/users/ShawnMilo/followers","following_url":"https://api.github.com/users/ShawnMilo/following{/other_user}","gists_url":"https://api.github.com/users/ShawnMilo/gists{/gist_id}","starred_url":"https://api.github.com/users/ShawnMilo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ShawnMilo/subscriptions","organizations_url":"https://api.github.com/users/ShawnMilo/orgs","repos_url":"https://api.github.com/users/ShawnMilo/repos","events_url":"https://api.github.com/users/ShawnMilo/events{/privacy}","received_events_url":"https://api.github.com/users/ShawnMilo/received_events","type":"User","site_admin":false},"body":"Yeah, that depends on how they implement it. If they choose to do that we can adapt. I'll mention it while I'm asking about the multiple concurrent course requests.","created_at":"2015-07-23T14:43:37Z","updated_at":"2015-07-23T14:43:37Z","html_url":"https://github.com/mitodl/lore/pull/403#discussion_r35328507","pull_request_url":"https://api.github.com/repos/mitodl/lore/pulls/403","_links":{"self":{"href":"https://api.github.com/repos/mitodl/lore/pulls/comments/35328507"},"html":{"href":"https://github.com/mitodl/lore/pull/403#discussion_r35328507"},"pull_request":{"href":"https://api.github.com/repos/mitodl/lore/pulls/403"}}},"pull_request":{"url":"https://api.github.com/repos/mitodl/lore/pulls/403","id":40595352,"html_url":"https://github.com/mitodl/lore/pull/403","diff_url":"https://github.com/mitodl/lore/pull/403.diff","patch_url":"https://github.com/mitodl/lore/pull/403.patch","issue_url":"https://api.github.com/repos/mitodl/lore/issues/403","number":403,"state":"open","locked":false,"title":"import xanalytics data","user":{"login":"ShawnMilo","id":130120,"avatar_url":"https://avatars.githubusercontent.com/u/130120?v=3","gravatar_id":"","url":"https://api.github.com/users/ShawnMilo","html_url":"https://github.com/ShawnMilo","followers_url":"https://api.github.com/users/ShawnMilo/followers","following_url":"https://api.github.com/users/ShawnMilo/following{/other_user}","gists_url":"https://api.github.com/users/ShawnMilo/gists{/gist_id}","starred_url":"https://api.github.com/users/ShawnMilo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ShawnMilo/subscriptions","organizations_url":"https://api.github.com/users/ShawnMilo/orgs","repos_url":"https://api.github.com/users/ShawnMilo/repos","events_url":"https://api.github.com/users/ShawnMilo/events{/privacy}","received_events_url":"https://api.github.com/users/ShawnMilo/received_events","type":"User","site_admin":false},"body":"closes #166\r\n\r\nUses [responses](https://pypi.python.org/pypi/responses/0.4.0)\r\nfor testing API calls, based on\r\n[this blog post](http://cramer.io/2014/05/20/mocking-requests-with-responses/).","created_at":"2015-07-22T18:21:00Z","updated_at":"2015-07-23T14:43:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a6876518bfc4e51e7a5f526bcaae2aee9a760077","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mitodl/lore/pulls/403/commits","review_comments_url":"https://api.github.com/repos/mitodl/lore/pulls/403/comments","review_comment_url":"https://api.github.com/repos/mitodl/lore/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mitodl/lore/issues/403/comments","statuses_url":"https://api.github.com/repos/mitodl/lore/statuses/d92eb3f52d5a5a13f1097739ca82212e1f636327","head":{"label":"mitodl:feature/skm/166_xanalytics","ref":"feature/skm/166_xanalytics","sha":"d92eb3f52d5a5a13f1097739ca82212e1f636327","user":{"login":"mitodl","id":7918516,"avatar_url":"https://avatars.githubusercontent.com/u/7918516?v=3","gravatar_id":"","url":"https://api.github.com/users/mitodl","html_url":"https://github.com/mitodl","followers_url":"https://api.github.com/users/mitodl/followers","following_url":"https://api.github.com/users/mitodl/following{/other_user}","gists_url":"https://api.github.com/users/mitodl/gists{/gist_id}","starred_url":"https://api.github.com/users/mitodl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitodl/subscriptions","organizations_url":"https://api.github.com/users/mitodl/orgs","repos_url":"https://api.github.com/users/mitodl/repos","events_url":"https://api.github.com/users/mitodl/events{/privacy}","received_events_url":"https://api.github.com/users/mitodl/received_events","type":"Organization","site_admin":false},"repo":{"id":34909549,"name":"lore","full_name":"mitodl/lore","owner":{"login":"mitodl","id":7918516,"avatar_url":"https://avatars.githubusercontent.com/u/7918516?v=3","gravatar_id":"","url":"https://api.github.com/users/mitodl","html_url":"https://github.com/mitodl","followers_url":"https://api.github.com/users/mitodl/followers","following_url":"https://api.github.com/users/mitodl/following{/other_user}","gists_url":"https://api.github.com/users/mitodl/gists{/gist_id}","starred_url":"https://api.github.com/users/mitodl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitodl/subscriptions","organizations_url":"https://api.github.com/users/mitodl/orgs","repos_url":"https://api.github.com/users/mitodl/repos","events_url":"https://api.github.com/users/mitodl/events{/privacy}","received_events_url":"https://api.github.com/users/mitodl/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mitodl/lore","description":"Learning Object Repository for Education","fork":false,"url":"https://api.github.com/repos/mitodl/lore","forks_url":"https://api.github.com/repos/mitodl/lore/forks","keys_url":"https://api.github.com/repos/mitodl/lore/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mitodl/lore/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mitodl/lore/teams","hooks_url":"https://api.github.com/repos/mitodl/lore/hooks","issue_events_url":"https://api.github.com/repos/mitodl/lore/issues/events{/number}","events_url":"https://api.github.com/repos/mitodl/lore/events","assignees_url":"https://api.github.com/repos/mitodl/lore/assignees{/user}","branches_url":"https://api.github.com/repos/mitodl/lore/branches{/branch}","tags_url":"https://api.github.com/repos/mitodl/lore/tags","blobs_url":"https://api.github.com/repos/mitodl/lore/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mitodl/lore/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mitodl/lore/git/refs{/sha}","trees_url":"https://api.github.com/repos/mitodl/lore/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mitodl/lore/statuses/{sha}","languages_url":"https://api.github.com/repos/mitodl/lore/languages","stargazers_url":"https://api.github.com/repos/mitodl/lore/stargazers","contributors_url":"https://api.github.com/repos/mitodl/lore/contributors","subscribers_url":"https://api.github.com/repos/mitodl/lore/subscribers","subscription_url":"https://api.github.com/repos/mitodl/lore/subscription","commits_url":"https://api.github.com/repos/mitodl/lore/commits{/sha}","git_commits_url":"https://api.github.com/repos/mitodl/lore/git/commits{/sha}","comments_url":"https://api.github.com/repos/mitodl/lore/comments{/number}","issue_comment_url":"https://api.github.com/repos/mitodl/lore/issues/comments{/number}","contents_url":"https://api.github.com/repos/mitodl/lore/contents/{+path}","compare_url":"https://api.github.com/repos/mitodl/lore/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mitodl/lore/merges","archive_url":"https://api.github.com/repos/mitodl/lore/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mitodl/lore/downloads","issues_url":"https://api.github.com/repos/mitodl/lore/issues{/number}","pulls_url":"https://api.github.com/repos/mitodl/lore/pulls{/number}","milestones_url":"https://api.github.com/repos/mitodl/lore/milestones{/number}","notifications_url":"https://api.github.com/repos/mitodl/lore/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mitodl/lore/labels{/name}","releases_url":"https://api.github.com/repos/mitodl/lore/releases{/id}","created_at":"2015-05-01T15:34:34Z","updated_at":"2015-06-17T02:41:03Z","pushed_at":"2015-07-23T13:17:59Z","git_url":"git://github.com/mitodl/lore.git","ssh_url":"git@github.com:mitodl/lore.git","clone_url":"https://github.com/mitodl/lore.git","svn_url":"https://github.com/mitodl/lore","homepage":"https://goo.gl/nDVx4D","size":7693,"stargazers_count":6,"watchers_count":6,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":80,"forks":2,"open_issues":80,"watchers":6,"default_branch":"master"}},"base":{"label":"mitodl:master","ref":"master","sha":"b51f4a67a69dddcc65d0746c857084dcfe79bf8d","user":{"login":"mitodl","id":7918516,"avatar_url":"https://avatars.githubusercontent.com/u/7918516?v=3","gravatar_id":"","url":"https://api.github.com/users/mitodl","html_url":"https://github.com/mitodl","followers_url":"https://api.github.com/users/mitodl/followers","following_url":"https://api.github.com/users/mitodl/following{/other_user}","gists_url":"https://api.github.com/users/mitodl/gists{/gist_id}","starred_url":"https://api.github.com/users/mitodl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitodl/subscriptions","organizations_url":"https://api.github.com/users/mitodl/orgs","repos_url":"https://api.github.com/users/mitodl/repos","events_url":"https://api.github.com/users/mitodl/events{/privacy}","received_events_url":"https://api.github.com/users/mitodl/received_events","type":"Organization","site_admin":false},"repo":{"id":34909549,"name":"lore","full_name":"mitodl/lore","owner":{"login":"mitodl","id":7918516,"avatar_url":"https://avatars.githubusercontent.com/u/7918516?v=3","gravatar_id":"","url":"https://api.github.com/users/mitodl","html_url":"https://github.com/mitodl","followers_url":"https://api.github.com/users/mitodl/followers","following_url":"https://api.github.com/users/mitodl/following{/other_user}","gists_url":"https://api.github.com/users/mitodl/gists{/gist_id}","starred_url":"https://api.github.com/users/mitodl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitodl/subscriptions","organizations_url":"https://api.github.com/users/mitodl/orgs","repos_url":"https://api.github.com/users/mitodl/repos","events_url":"https://api.github.com/users/mitodl/events{/privacy}","received_events_url":"https://api.github.com/users/mitodl/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mitodl/lore","description":"Learning Object Repository for Education","fork":false,"url":"https://api.github.com/repos/mitodl/lore","forks_url":"https://api.github.com/repos/mitodl/lore/forks","keys_url":"https://api.github.com/repos/mitodl/lore/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mitodl/lore/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mitodl/lore/teams","hooks_url":"https://api.github.com/repos/mitodl/lore/hooks","issue_events_url":"https://api.github.com/repos/mitodl/lore/issues/events{/number}","events_url":"https://api.github.com/repos/mitodl/lore/events","assignees_url":"https://api.github.com/repos/mitodl/lore/assignees{/user}","branches_url":"https://api.github.com/repos/mitodl/lore/branches{/branch}","tags_url":"https://api.github.com/repos/mitodl/lore/tags","blobs_url":"https://api.github.com/repos/mitodl/lore/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mitodl/lore/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mitodl/lore/git/refs{/sha}","trees_url":"https://api.github.com/repos/mitodl/lore/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mitodl/lore/statuses/{sha}","languages_url":"https://api.github.com/repos/mitodl/lore/languages","stargazers_url":"https://api.github.com/repos/mitodl/lore/stargazers","contributors_url":"https://api.github.com/repos/mitodl/lore/contributors","subscribers_url":"https://api.github.com/repos/mitodl/lore/subscribers","subscription_url":"https://api.github.com/repos/mitodl/lore/subscription","commits_url":"https://api.github.com/repos/mitodl/lore/commits{/sha}","git_commits_url":"https://api.github.com/repos/mitodl/lore/git/commits{/sha}","comments_url":"https://api.github.com/repos/mitodl/lore/comments{/number}","issue_comment_url":"https://api.github.com/repos/mitodl/lore/issues/comments{/number}","contents_url":"https://api.github.com/repos/mitodl/lore/contents/{+path}","compare_url":"https://api.github.com/repos/mitodl/lore/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mitodl/lore/merges","archive_url":"https://api.github.com/repos/mitodl/lore/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mitodl/lore/downloads","issues_url":"https://api.github.com/repos/mitodl/lore/issues{/number}","pulls_url":"https://api.github.com/repos/mitodl/lore/pulls{/number}","milestones_url":"https://api.github.com/repos/mitodl/lore/milestones{/number}","notifications_url":"https://api.github.com/repos/mitodl/lore/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mitodl/lore/labels{/name}","releases_url":"https://api.github.com/repos/mitodl/lore/releases{/id}","created_at":"2015-05-01T15:34:34Z","updated_at":"2015-06-17T02:41:03Z","pushed_at":"2015-07-23T13:17:59Z","git_url":"git://github.com/mitodl/lore.git","ssh_url":"git@github.com:mitodl/lore.git","clone_url":"https://github.com/mitodl/lore.git","svn_url":"https://github.com/mitodl/lore","homepage":"https://goo.gl/nDVx4D","size":7693,"stargazers_count":6,"watchers_count":6,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":80,"forks":2,"open_issues":80,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mitodl/lore/pulls/403"},"html":{"href":"https://github.com/mitodl/lore/pull/403"},"issue":{"href":"https://api.github.com/repos/mitodl/lore/issues/403"},"comments":{"href":"https://api.github.com/repos/mitodl/lore/issues/403/comments"},"review_comments":{"href":"https://api.github.com/repos/mitodl/lore/pulls/403/comments"},"review_comment":{"href":"https://api.github.com/repos/mitodl/lore/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mitodl/lore/pulls/403/commits"},"statuses":{"href":"https://api.github.com/repos/mitodl/lore/statuses/d92eb3f52d5a5a13f1097739ca82212e1f636327"}}}}