{"action":"created","comment":{"url":"https://api.github.com/repos/edx/edx-analytics-dashboard/pulls/comments/114643988","pull_request_review_id":36128478,"id":114643988,"diff_hunk":"@@ -0,0 +1,60 @@\n+from courses.presenters import BasePresenter\n+from django.core.cache import cache\n+\n+\n+class ProgramsPresenter(BasePresenter):\n+    \"\"\" Presenter for the programs metadata. \"\"\"\n+\n+    CACHE_KEY = 'programs'\n+    NON_NULL_STRING_FIELDS = ['program_id', 'program_type', 'program_title']\n+\n+    @staticmethod\n+    def filter_programs(all_programs, program_ids=None, course_ids=None):\n+        \"\"\"Filter results to just the program IDs specified and then to just the programs that have\n+           a course in the given course_ids list.\n+        \"\"\"\n+        if program_ids is None:\n+            programs = all_programs\n+        else:\n+            programs = [program for program in all_programs if program['program_id'] in program_ids]\n+\n+        # Now apply course_ids filter\n+        if course_ids is None:\n+            return programs\n+        else:\n+            filtered_programs = []\n+            for program in programs:\n+                for course_id in course_ids:\n+                    if course_id in program['course_ids']:\n+                        filtered_programs.append(program)\n+                        break","path":"analytics_dashboard/courses/presenters/programs.py","position":30,"original_position":30,"commit_id":"2054bc0c53cf4f41ad0bdbb8561433976e697807","original_commit_id":"2054bc0c53cf4f41ad0bdbb8561433976e697807","user":{"login":"dsjen","id":5265058,"avatar_url":"https://avatars3.githubusercontent.com/u/5265058?v=3","gravatar_id":"","url":"https://api.github.com/users/dsjen","html_url":"https://github.com/dsjen","followers_url":"https://api.github.com/users/dsjen/followers","following_url":"https://api.github.com/users/dsjen/following{/other_user}","gists_url":"https://api.github.com/users/dsjen/gists{/gist_id}","starred_url":"https://api.github.com/users/dsjen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dsjen/subscriptions","organizations_url":"https://api.github.com/users/dsjen/orgs","repos_url":"https://api.github.com/users/dsjen/repos","events_url":"https://api.github.com/users/dsjen/events{/privacy}","received_events_url":"https://api.github.com/users/dsjen/received_events","type":"User","site_admin":false},"body":"Woohoo!  Glad you found where the bug was.  I just found a way that we could do this in a more performant way using sets.  Check out http://stackoverflow.com/questions/3170055/test-if-lists-share-any-items-in-python.  What do you think?\r\n\r\nI guess it would look something like:\r\n```\r\nif not set(program['course_ids']).isdisjoint(course_ids):\r\n    filtered_programs.append(program)\r\n```","created_at":"2017-05-03T20:24:34Z","updated_at":"2017-05-03T20:24:34Z","html_url":"https://github.com/edx/edx-analytics-dashboard/pull/666#discussion_r114643988","pull_request_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/pulls/666","_links":{"self":{"href":"https://api.github.com/repos/edx/edx-analytics-dashboard/pulls/comments/114643988"},"html":{"href":"https://github.com/edx/edx-analytics-dashboard/pull/666#discussion_r114643988"},"pull_request":{"href":"https://api.github.com/repos/edx/edx-analytics-dashboard/pulls/666"}}},"pull_request":{"url":"https://api.github.com/repos/edx/edx-analytics-dashboard/pulls/666","id":117726818,"html_url":"https://github.com/edx/edx-analytics-dashboard/pull/666","diff_url":"https://github.com/edx/edx-analytics-dashboard/pull/666.diff","patch_url":"https://github.com/edx/edx-analytics-dashboard/pull/666.patch","issue_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/issues/666","number":666,"state":"open","locked":false,"title":"AN-8556 Courses Page programs filter","user":{"login":"thallada","id":1505923,"avatar_url":"https://avatars0.githubusercontent.com/u/1505923?v=3","gravatar_id":"","url":"https://api.github.com/users/thallada","html_url":"https://github.com/thallada","followers_url":"https://api.github.com/users/thallada/followers","following_url":"https://api.github.com/users/thallada/following{/other_user}","gists_url":"https://api.github.com/users/thallada/gists{/gist_id}","starred_url":"https://api.github.com/users/thallada/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thallada/subscriptions","organizations_url":"https://api.github.com/users/thallada/orgs","repos_url":"https://api.github.com/users/thallada/repos","events_url":"https://api.github.com/users/thallada/events{/privacy}","received_events_url":"https://api.github.com/users/thallada/received_events","type":"User","site_admin":false},"body":"Adds another filter type: `program_ids` which will appear as a list of checkboxes, one for every program that has a course that the user has access to.\r\n\r\nThis filter uses the new programs endpoint in the data API during the initial fetch.","created_at":"2017-04-26T14:21:38Z","updated_at":"2017-05-03T20:24:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"088c2698063342fd8518e5ebce8dca1542ca8f67","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/pulls/666/commits","review_comments_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/pulls/666/comments","review_comment_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/pulls/comments{/number}","comments_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/issues/666/comments","statuses_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/statuses/2054bc0c53cf4f41ad0bdbb8561433976e697807","head":{"label":"edx:thallada/programs-filter","ref":"thallada/programs-filter","sha":"2054bc0c53cf4f41ad0bdbb8561433976e697807","user":{"login":"edx","id":3179841,"avatar_url":"https://avatars0.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":20941273,"name":"edx-analytics-dashboard","full_name":"edx/edx-analytics-dashboard","owner":{"login":"edx","id":3179841,"avatar_url":"https://avatars0.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-analytics-dashboard","description":"Dashboard to display course analytics to course teams","fork":false,"url":"https://api.github.com/repos/edx/edx-analytics-dashboard","forks_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/forks","keys_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/teams","hooks_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/hooks","issue_events_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/issues/events{/number}","events_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/events","assignees_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/assignees{/user}","branches_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/branches{/branch}","tags_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/tags","blobs_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/languages","stargazers_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/stargazers","contributors_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/contributors","subscribers_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/subscribers","subscription_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/subscription","commits_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/contents/{+path}","compare_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/merges","archive_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/downloads","issues_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/issues{/number}","pulls_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/labels{/name}","releases_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/releases{/id}","deployments_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/deployments","created_at":"2014-06-17T22:14:33Z","updated_at":"2017-02-26T20:06:49Z","pushed_at":"2017-05-03T20:05:56Z","git_url":"git://github.com/edx/edx-analytics-dashboard.git","ssh_url":"git@github.com:edx/edx-analytics-dashboard.git","clone_url":"https://github.com/edx/edx-analytics-dashboard.git","svn_url":"https://github.com/edx/edx-analytics-dashboard","homepage":null,"size":25741,"stargazers_count":32,"watchers_count":32,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":63,"mirror_url":null,"open_issues_count":3,"forks":63,"open_issues":3,"watchers":32,"default_branch":"master"}},"base":{"label":"edx:master","ref":"master","sha":"1a93b8e7db1f2058716877b14a1a319296dbb5ea","user":{"login":"edx","id":3179841,"avatar_url":"https://avatars0.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":20941273,"name":"edx-analytics-dashboard","full_name":"edx/edx-analytics-dashboard","owner":{"login":"edx","id":3179841,"avatar_url":"https://avatars0.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-analytics-dashboard","description":"Dashboard to display course analytics to course teams","fork":false,"url":"https://api.github.com/repos/edx/edx-analytics-dashboard","forks_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/forks","keys_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/teams","hooks_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/hooks","issue_events_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/issues/events{/number}","events_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/events","assignees_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/assignees{/user}","branches_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/branches{/branch}","tags_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/tags","blobs_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/languages","stargazers_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/stargazers","contributors_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/contributors","subscribers_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/subscribers","subscription_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/subscription","commits_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/contents/{+path}","compare_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/merges","archive_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/downloads","issues_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/issues{/number}","pulls_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/labels{/name}","releases_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/releases{/id}","deployments_url":"https://api.github.com/repos/edx/edx-analytics-dashboard/deployments","created_at":"2014-06-17T22:14:33Z","updated_at":"2017-02-26T20:06:49Z","pushed_at":"2017-05-03T20:05:56Z","git_url":"git://github.com/edx/edx-analytics-dashboard.git","ssh_url":"git@github.com:edx/edx-analytics-dashboard.git","clone_url":"https://github.com/edx/edx-analytics-dashboard.git","svn_url":"https://github.com/edx/edx-analytics-dashboard","homepage":null,"size":25741,"stargazers_count":32,"watchers_count":32,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":63,"mirror_url":null,"open_issues_count":3,"forks":63,"open_issues":3,"watchers":32,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/edx/edx-analytics-dashboard/pulls/666"},"html":{"href":"https://github.com/edx/edx-analytics-dashboard/pull/666"},"issue":{"href":"https://api.github.com/repos/edx/edx-analytics-dashboard/issues/666"},"comments":{"href":"https://api.github.com/repos/edx/edx-analytics-dashboard/issues/666/comments"},"review_comments":{"href":"https://api.github.com/repos/edx/edx-analytics-dashboard/pulls/666/comments"},"review_comment":{"href":"https://api.github.com/repos/edx/edx-analytics-dashboard/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/edx/edx-analytics-dashboard/pulls/666/commits"},"statuses":{"href":"https://api.github.com/repos/edx/edx-analytics-dashboard/statuses/2054bc0c53cf4f41ad0bdbb8561433976e697807"}}}}
{"actor":{"display_login":"dsjen"}}