{"action":"created","comment":{"url":"https://api.github.com/repos/edx/edx-platform/pulls/comments/88053989","pull_request_review_id":8635716,"id":88053989,"diff_hunk":"@@ -168,18 +164,55 @@ def add_to_transaction(neo4j_entities, transaction):\n             transaction.create(entity)\n \n     @staticmethod\n-    def should_dump_course(course_key):\n+    def get_command_last_run(course_key, graph):\n+        \"\"\"\n+        This information is stored on the course node of a course in neo4j\n+        :param course_key: a CourseKey\n+        :param graph: a py2neo Graph\n+        :return: a string representation of when this course was last dumped to\n+         neo4j or None\n+        \"\"\"\n+        selector = NodeSelector(graph)\n+        course_node = selector.select(\n+            \"course\",\n+            course_key=six.text_type(course_key)\n+        ).first()\n+\n+        last_this_command_was_run = None\n+        if course_node is not None:\n+            last_this_command_was_run = course_node['time_last_dumped_to_neo4j']\n+\n+        return last_this_command_was_run\n+\n+    @staticmethod\n+    def get_course_last_published(course_key):\n+        \"\"\"\n+        We use the CourseStructure table to get when this course was last\n+          published.\n+        :param course_key: a CourseKey\n+        :return: a string representation of when this course was last dumped to\n+          neo4j or None\n+        \"\"\"\n+        try:\n+            structure = CourseStructure.objects.get(course_id=course_key)\n+            last_course_had_published_event = six.text_type(structure.modified)\n+        except CourseStructure.DoesNotExist:\n+            last_course_had_published_event = None\n+\n+        return last_course_had_published_event\n+\n+    def should_dump_course(self, course_key, graph):\n         \"\"\"\n         Only dump the course if it's been changed since the last time it's been\n         dumped.\n         :param course_key: a CourseKey object.\n+        :param graph: a py2neo Graph object.\n         :return: bool. Whether or not this course should be dumped to neo4j.\n         \"\"\"\n \n-        last_this_command_was_run = COMMAND_LAST_RUN_CACHE.get(course_key)\n-        last_course_had_published_event = COURSE_LAST_PUBLISHED_CACHE.get(\n-            course_key\n-        )\n+        last_this_command_was_run = self.get_command_last_run(course_key, graph)\n+\n+        last_course_had_published_event = self.get_course_last_published(course_key)\n \n         # if we have no record of this course being serialized, serialize it","path":"openedx/core/djangoapps/coursegraph/management/commands/dump_to_neo4j.py","position":107,"original_position":107,"commit_id":"a5150bfffcceb6c22e14f2ca6e8c9ba009beb726","original_commit_id":"79d04a50bf7eb9547fa880e1a3a3dd91ffc86ffb","user":{"login":"awaisdar001","id":4252738,"avatar_url":"https://avatars.githubusercontent.com/u/4252738?v=3","gravatar_id":"","url":"https://api.github.com/users/awaisdar001","html_url":"https://github.com/awaisdar001","followers_url":"https://api.github.com/users/awaisdar001/followers","following_url":"https://api.github.com/users/awaisdar001/following{/other_user}","gists_url":"https://api.github.com/users/awaisdar001/gists{/gist_id}","starred_url":"https://api.github.com/users/awaisdar001/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/awaisdar001/subscriptions","organizations_url":"https://api.github.com/users/awaisdar001/orgs","repos_url":"https://api.github.com/users/awaisdar001/repos","events_url":"https://api.github.com/users/awaisdar001/events{/privacy}","received_events_url":"https://api.github.com/users/awaisdar001/received_events","type":"User","site_admin":false},"body":"This comment is confusing, this method is only making a decision `if dump the course is changed`. I think making a single exit point will also address this. ","created_at":"2016-11-15T16:25:10Z","updated_at":"2016-11-15T16:47:20Z","html_url":"https://github.com/edx/edx-platform/pull/13992#discussion_r88053989","pull_request_url":"https://api.github.com/repos/edx/edx-platform/pulls/13992","_links":{"self":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/comments/88053989"},"html":{"href":"https://github.com/edx/edx-platform/pull/13992#discussion_r88053989"},"pull_request":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/13992"}}},"pull_request":{"url":"https://api.github.com/repos/edx/edx-platform/pulls/13992","id":93792827,"html_url":"https://github.com/edx/edx-platform/pull/13992","diff_url":"https://github.com/edx/edx-platform/pull/13992.diff","patch_url":"https://github.com/edx/edx-platform/pull/13992.patch","issue_url":"https://api.github.com/repos/edx/edx-platform/issues/13992","number":13992,"state":"open","locked":false,"title":"Moves dump_to_neo4j cache backend to neo4j instead of memcached (SUST…","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":"…-76)\r\n\r\n\r\n## [SUST-76](https://openedx.atlassian.net/browse/SUST-76)\r\n\r\n### Description\r\n\r\n* Moves the `dump_to_neo4j` cache backend to neo4j instead of memcached\r\n* Instead of caching when a course is last published, we get this information\r\n  from the `CourseStructure` table\r\n* This commit introduces a mock py2neo Graph to be used for testing\r\n\r\n### How to Test?\r\nYou can set up a neo4j server locally (I'll need to release documentation for that). Or you can run the tests in this suite:\r\n`paver test_system -t openedx/core/djangoapps/coursegraph/management/commands/tests/test_dump_to_neo4j.py --fasttest --disable-migrations`\r\n\r\n**Stage**: \r\nN/A: \r\n\r\n**Sandbox**\r\nI haven't been able to get coursegraph set up on a sandbox\r\n\r\n**Screenshot**\r\nN/A\r\n\r\n\r\n### Reviewers\r\nIf you've been tagged for review, please check your corresponding box once you've given the thumbs up.\r\n- [ ] F.I.R: @awaisdar001 \r\n- [ ] Code review: @fredsmith \r\n- [ ] Code review: @benpatterson (Ben, there's a pretty big testing philosophy change here, stubbing out the neo4j graph object. I'd love to get your take on that in particular)\r\n\r\nFYI: Tag anyone who might be interested in this PR here.\r\n\r\n### Post-review\r\n- [ ] Rebase and squash commits","created_at":"2016-11-15T15:57:04Z","updated_at":"2016-11-15T16:47:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"45eb553d1456fac8cf52a5229716f1b33ae8d02e","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/edx/edx-platform/pulls/13992/commits","review_comments_url":"https://api.github.com/repos/edx/edx-platform/pulls/13992/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/13992/comments","statuses_url":"https://api.github.com/repos/edx/edx-platform/statuses/a5150bfffcceb6c22e14f2ca6e8c9ba009beb726","head":{"label":"edx:adam/refactor-dump-to-neo4j-caching","ref":"adam/refactor-dump-to-neo4j-caching","sha":"a5150bfffcceb6c22e14f2ca6e8c9ba009beb726","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":"The Open edX platform, the software that powers edX!","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}","deployments_url":"https://api.github.com/repos/edx/edx-platform/deployments","created_at":"2013-05-30T20:20:38Z","updated_at":"2016-11-15T16:07:43Z","pushed_at":"2016-11-15T16:46:37Z","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://open.edx.org/","size":872810,"stargazers_count":2856,"watchers_count":2856,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1698,"mirror_url":null,"open_issues_count":158,"forks":1698,"open_issues":158,"watchers":2856,"default_branch":"master"}},"base":{"label":"edx:master","ref":"master","sha":"48507af2292823f8b58c3aa02c8c0abb26500793","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":"The Open edX platform, the software that powers edX!","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}","deployments_url":"https://api.github.com/repos/edx/edx-platform/deployments","created_at":"2013-05-30T20:20:38Z","updated_at":"2016-11-15T16:07:43Z","pushed_at":"2016-11-15T16:46:37Z","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://open.edx.org/","size":872810,"stargazers_count":2856,"watchers_count":2856,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1698,"mirror_url":null,"open_issues_count":158,"forks":1698,"open_issues":158,"watchers":2856,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/13992"},"html":{"href":"https://github.com/edx/edx-platform/pull/13992"},"issue":{"href":"https://api.github.com/repos/edx/edx-platform/issues/13992"},"comments":{"href":"https://api.github.com/repos/edx/edx-platform/issues/13992/comments"},"review_comments":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/13992/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/13992/commits"},"statuses":{"href":"https://api.github.com/repos/edx/edx-platform/statuses/a5150bfffcceb6c22e14f2ca6e8c9ba009beb726"}}}}
{"actor":{"display_login":"awaisdar001"}}