{"action":"created","comment":{"url":"https://api.github.com/repos/edx/credentials/pulls/comments/90732109","pull_request_review_id":11253021,"id":90732109,"diff_hunk":"@@ -0,0 +1,34 @@\n+import logging\n+\n+from credentials.apps.credentials.utils import get_program\n+from django.core.management.base import BaseCommand\n+from credentials.apps.credentials.models import ProgramCertificate\n+\n+logger = logging.getLogger(__name__)\n+\n+\n+class Command(BaseCommand):\n+    help = 'Add missing UUIDs to the programCertificate table'\n+\n+    def get_uuid_from_api(self, id=None):\n+        if id is None:\n+            raise AttributeError('Need an ID')\n+\n+        item = get_program(id)\n+        return item['uuid']\n+\n+    def handle(self, *args, **options):\n+        \"\"\" Add missing UUIDs to the programCertificate table\"\"\"\n+\n+        program_certificate_table = ProgramCertificate.objects.filter(program_uuid__isnull=True)\n+\n+        for program_entry in program_certificate_table:\n+            try:\n+                logger.info('Getting UUID for {}'.format(program_entry.program_id))\n+                program_entry.program_uuid = self.get_uuid_from_api(program_entry.program_id)","path":"credentials/apps/credentials/management/commands/add_uuids_to_program_certificates.py","position":28,"original_position":28,"commit_id":"d5fa357484b13f5e5be38f252bee19cd8036b31d","original_commit_id":"d5fa357484b13f5e5be38f252bee19cd8036b31d","user":{"login":"schenedx","id":16839373,"avatar_url":"https://avatars.githubusercontent.com/u/16839373?v=3","gravatar_id":"","url":"https://api.github.com/users/schenedx","html_url":"https://github.com/schenedx","followers_url":"https://api.github.com/users/schenedx/followers","following_url":"https://api.github.com/users/schenedx/following{/other_user}","gists_url":"https://api.github.com/users/schenedx/gists{/gist_id}","starred_url":"https://api.github.com/users/schenedx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/schenedx/subscriptions","organizations_url":"https://api.github.com/users/schenedx/orgs","repos_url":"https://api.github.com/users/schenedx/repos","events_url":"https://api.github.com/users/schenedx/events{/privacy}","received_events_url":"https://api.github.com/users/schenedx/received_events","type":"User","site_admin":false},"body":"Instead of getting the program one by one from the API, why can't we just go ahead and get all programs from the API and store that in django cache or in memory dictionary? Then when you are editing each program,  you can use the dictionary to find the UUID. This avoids so many API calls","created_at":"2016-12-02T22:33:13Z","updated_at":"2016-12-02T22:33:13Z","html_url":"https://github.com/edx/credentials/pull/129#discussion_r90732109","pull_request_url":"https://api.github.com/repos/edx/credentials/pulls/129","_links":{"self":{"href":"https://api.github.com/repos/edx/credentials/pulls/comments/90732109"},"html":{"href":"https://github.com/edx/credentials/pull/129#discussion_r90732109"},"pull_request":{"href":"https://api.github.com/repos/edx/credentials/pulls/129"}}},"pull_request":{"url":"https://api.github.com/repos/edx/credentials/pulls/129","id":96352092,"html_url":"https://github.com/edx/credentials/pull/129","diff_url":"https://github.com/edx/credentials/pull/129.diff","patch_url":"https://github.com/edx/credentials/pull/129.patch","issue_url":"https://api.github.com/repos/edx/credentials/issues/129","number":129,"state":"open","locked":false,"title":"Added mgmt command to add UUIDs to program certificates table.","user":{"login":"davec-edx","id":23459900,"avatar_url":"https://avatars.githubusercontent.com/u/23459900?v=3","gravatar_id":"","url":"https://api.github.com/users/davec-edx","html_url":"https://github.com/davec-edx","followers_url":"https://api.github.com/users/davec-edx/followers","following_url":"https://api.github.com/users/davec-edx/following{/other_user}","gists_url":"https://api.github.com/users/davec-edx/gists{/gist_id}","starred_url":"https://api.github.com/users/davec-edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davec-edx/subscriptions","organizations_url":"https://api.github.com/users/davec-edx/orgs","repos_url":"https://api.github.com/users/davec-edx/repos","events_url":"https://api.github.com/users/davec-edx/events{/privacy}","received_events_url":"https://api.github.com/users/davec-edx/received_events","type":"User","site_admin":false},"body":"ECOM-6485\r\n\r\n@edx/ecommerce \r\n\r\nPlease review\r\nthanks","created_at":"2016-12-02T21:01:43Z","updated_at":"2016-12-02T22:33:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b27e84f4429efc536d24e023f3d0771a98287ab2","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/edx/credentials/pulls/129/commits","review_comments_url":"https://api.github.com/repos/edx/credentials/pulls/129/comments","review_comment_url":"https://api.github.com/repos/edx/credentials/pulls/comments{/number}","comments_url":"https://api.github.com/repos/edx/credentials/issues/129/comments","statuses_url":"https://api.github.com/repos/edx/credentials/statuses/d5fa357484b13f5e5be38f252bee19cd8036b31d","head":{"label":"edx:ecom6485","ref":"ecom6485","sha":"d5fa357484b13f5e5be38f252bee19cd8036b31d","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":47830104,"name":"credentials","full_name":"edx/credentials","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/credentials","description":"Django application used as the backend to support Course or Program based credentials.","fork":false,"url":"https://api.github.com/repos/edx/credentials","forks_url":"https://api.github.com/repos/edx/credentials/forks","keys_url":"https://api.github.com/repos/edx/credentials/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/credentials/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/credentials/teams","hooks_url":"https://api.github.com/repos/edx/credentials/hooks","issue_events_url":"https://api.github.com/repos/edx/credentials/issues/events{/number}","events_url":"https://api.github.com/repos/edx/credentials/events","assignees_url":"https://api.github.com/repos/edx/credentials/assignees{/user}","branches_url":"https://api.github.com/repos/edx/credentials/branches{/branch}","tags_url":"https://api.github.com/repos/edx/credentials/tags","blobs_url":"https://api.github.com/repos/edx/credentials/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/credentials/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/credentials/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/credentials/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/credentials/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/credentials/languages","stargazers_url":"https://api.github.com/repos/edx/credentials/stargazers","contributors_url":"https://api.github.com/repos/edx/credentials/contributors","subscribers_url":"https://api.github.com/repos/edx/credentials/subscribers","subscription_url":"https://api.github.com/repos/edx/credentials/subscription","commits_url":"https://api.github.com/repos/edx/credentials/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/credentials/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/credentials/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/credentials/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx/credentials/contents/{+path}","compare_url":"https://api.github.com/repos/edx/credentials/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/credentials/merges","archive_url":"https://api.github.com/repos/edx/credentials/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/credentials/downloads","issues_url":"https://api.github.com/repos/edx/credentials/issues{/number}","pulls_url":"https://api.github.com/repos/edx/credentials/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/credentials/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/credentials/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/credentials/labels{/name}","releases_url":"https://api.github.com/repos/edx/credentials/releases{/id}","deployments_url":"https://api.github.com/repos/edx/credentials/deployments","created_at":"2015-12-11T14:09:03Z","updated_at":"2016-11-01T21:52:04Z","pushed_at":"2016-12-02T21:01:43Z","git_url":"git://github.com/edx/credentials.git","ssh_url":"git@github.com:edx/credentials.git","clone_url":"https://github.com/edx/credentials.git","svn_url":"https://github.com/edx/credentials","homepage":"http://open-edx-credentials-guide.readthedocs.org/en/latest/ ","size":2846,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":3,"forks":2,"open_issues":3,"watchers":2,"default_branch":"master"}},"base":{"label":"edx:master","ref":"master","sha":"5dbf45e620075c927ad505ae8b45824adb38b22e","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":47830104,"name":"credentials","full_name":"edx/credentials","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/credentials","description":"Django application used as the backend to support Course or Program based credentials.","fork":false,"url":"https://api.github.com/repos/edx/credentials","forks_url":"https://api.github.com/repos/edx/credentials/forks","keys_url":"https://api.github.com/repos/edx/credentials/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/credentials/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/credentials/teams","hooks_url":"https://api.github.com/repos/edx/credentials/hooks","issue_events_url":"https://api.github.com/repos/edx/credentials/issues/events{/number}","events_url":"https://api.github.com/repos/edx/credentials/events","assignees_url":"https://api.github.com/repos/edx/credentials/assignees{/user}","branches_url":"https://api.github.com/repos/edx/credentials/branches{/branch}","tags_url":"https://api.github.com/repos/edx/credentials/tags","blobs_url":"https://api.github.com/repos/edx/credentials/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/credentials/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/credentials/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/credentials/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/credentials/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/credentials/languages","stargazers_url":"https://api.github.com/repos/edx/credentials/stargazers","contributors_url":"https://api.github.com/repos/edx/credentials/contributors","subscribers_url":"https://api.github.com/repos/edx/credentials/subscribers","subscription_url":"https://api.github.com/repos/edx/credentials/subscription","commits_url":"https://api.github.com/repos/edx/credentials/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/credentials/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/credentials/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/credentials/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx/credentials/contents/{+path}","compare_url":"https://api.github.com/repos/edx/credentials/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/credentials/merges","archive_url":"https://api.github.com/repos/edx/credentials/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/credentials/downloads","issues_url":"https://api.github.com/repos/edx/credentials/issues{/number}","pulls_url":"https://api.github.com/repos/edx/credentials/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/credentials/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/credentials/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/credentials/labels{/name}","releases_url":"https://api.github.com/repos/edx/credentials/releases{/id}","deployments_url":"https://api.github.com/repos/edx/credentials/deployments","created_at":"2015-12-11T14:09:03Z","updated_at":"2016-11-01T21:52:04Z","pushed_at":"2016-12-02T21:01:43Z","git_url":"git://github.com/edx/credentials.git","ssh_url":"git@github.com:edx/credentials.git","clone_url":"https://github.com/edx/credentials.git","svn_url":"https://github.com/edx/credentials","homepage":"http://open-edx-credentials-guide.readthedocs.org/en/latest/ ","size":2846,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":3,"forks":2,"open_issues":3,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/edx/credentials/pulls/129"},"html":{"href":"https://github.com/edx/credentials/pull/129"},"issue":{"href":"https://api.github.com/repos/edx/credentials/issues/129"},"comments":{"href":"https://api.github.com/repos/edx/credentials/issues/129/comments"},"review_comments":{"href":"https://api.github.com/repos/edx/credentials/pulls/129/comments"},"review_comment":{"href":"https://api.github.com/repos/edx/credentials/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/edx/credentials/pulls/129/commits"},"statuses":{"href":"https://api.github.com/repos/edx/credentials/statuses/d5fa357484b13f5e5be38f252bee19cd8036b31d"}}}}
{"actor":{"display_login":"schenedx"}}