{"action":"created","comment":{"url":"https://api.github.com/repos/dimagi/commcare-hq/pulls/comments/172418791","pull_request_review_id":101428955,"id":172418791,"diff_hunk":"@@ -354,6 +356,94 @@ def test_only_get_dependent_cases_on_phone(self):\n         raise NotImplementedError()\n \n \n+def save_synclog_to_sql(synclog_json_object):\n+    synclog = synclog_to_sql_object(synclog_json_object)\n+    synclog.save()\n+\n+\n+def delete_synclog(synclog_id):\n+    \"\"\"\n+    Deletes synclog object both from Couch and SQL, if the doc\n+        isn't found in either couch or SQL an exception is raised\n+    \"\"\"\n+    deleted = False\n+    try:\n+        synclog = SyncLogSQL.objects.filter(synclog_id=synclog_id).first()\n+        if synclog:\n+            synclog.delete()\n+            deleted = True\n+    except ValidationError:\n+        pass\n+\n+    try:\n+        synclog = properly_wrap_sync_log(SyncLog.get_db().get(synclog_id))\n+        SyncLog.get_db().delete_doc(synclog)\n+        deleted = True\n+    except ResourceNotFound:\n+        pass\n+\n+    if not deleted:\n+        raise MissingSyncLog(\"A SyncLogSQL object with this synclog_id ({})is not found\".format(synclog_id))\n+\n+\n+def synclog_to_sql_object(synclog_json_object):\n+    # Returns a SyncLogSQL object, a saved instance from DB or\n+    #   instantiated SQL object to be saved\n+    # synclog_json_object should be a SyncLog instance\n+    # if synclog_json_object._id\n+    synclog = None\n+    if synclog_json_object._id:\n+        synclog = SyncLogSQL.objects.filter(synclog_id=synclog_json_object._id).first()\n+\n+    is_new_synclog_sql = not synclog_json_object._id or not synclog\n+\n+    if is_new_synclog_sql:\n+        synclog_id = synclog_json_object._id or uuid.uuid1().hex.lower()\n+        synclog_json_object._id = synclog_id\n+        synclog = SyncLogSQL(\n+            domain=synclog_json_object.domain,\n+            user_id=synclog_json_object.user_id,\n+            synclog_id=synclog_id,\n+            date=synclog_json_object.date,\n+            previous_synclog_id=getattr(synclog_json_object, 'previous_log_id', None),\n+            log_format=synclog_json_object.log_format,\n+            build_id=synclog_json_object.build_id,\n+            duration=synclog_json_object.duration,\n+            last_submitted=synclog_json_object.last_submitted,\n+            had_state_error=synclog_json_object.had_state_error,\n+            error_date=synclog_json_object.error_date,\n+            error_hash=synclog_json_object.error_hash,\n+        )\n+    synclog.doc = synclog_json_object.to_json()\n+    return synclog\n+\n+\n+@architect.install('partition', type='range', subtype='date', constraint='day', column='date')","path":"corehq/ex-submodules/casexml/apps/phone/models.py","position":105,"original_position":105,"commit_id":"7c761167ecc5d4dbf6223d0c01bb3086acf2004a","original_commit_id":"32cd471d44a661c2648bddfc325fed9134475fe3","user":{"login":"sravfeyn","id":829142,"avatar_url":"https://avatars0.githubusercontent.com/u/829142?v=4","gravatar_id":"","url":"https://api.github.com/users/sravfeyn","html_url":"https://github.com/sravfeyn","followers_url":"https://api.github.com/users/sravfeyn/followers","following_url":"https://api.github.com/users/sravfeyn/following{/other_user}","gists_url":"https://api.github.com/users/sravfeyn/gists{/gist_id}","starred_url":"https://api.github.com/users/sravfeyn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sravfeyn/subscriptions","organizations_url":"https://api.github.com/users/sravfeyn/orgs","repos_url":"https://api.github.com/users/sravfeyn/repos","events_url":"https://api.github.com/users/sravfeyn/events{/privacy}","received_events_url":"https://api.github.com/users/sravfeyn/received_events","type":"User","site_admin":false},"body":"Updated","created_at":"2018-03-06T06:14:32Z","updated_at":"2018-03-06T06:14:32Z","html_url":"https://github.com/dimagi/commcare-hq/pull/19391#discussion_r172418791","pull_request_url":"https://api.github.com/repos/dimagi/commcare-hq/pulls/19391","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/dimagi/commcare-hq/pulls/comments/172418791"},"html":{"href":"https://github.com/dimagi/commcare-hq/pull/19391#discussion_r172418791"},"pull_request":{"href":"https://api.github.com/repos/dimagi/commcare-hq/pulls/19391"}},"in_reply_to_id":171096581},"pull_request":{"url":"https://api.github.com/repos/dimagi/commcare-hq/pulls/19391","id":168237186,"html_url":"https://github.com/dimagi/commcare-hq/pull/19391","diff_url":"https://github.com/dimagi/commcare-hq/pull/19391.diff","patch_url":"https://github.com/dimagi/commcare-hq/pull/19391.patch","issue_url":"https://api.github.com/repos/dimagi/commcare-hq/issues/19391","number":19391,"state":"open","locked":false,"title":"synclog to SQL","user":{"login":"sravfeyn","id":829142,"avatar_url":"https://avatars0.githubusercontent.com/u/829142?v=4","gravatar_id":"","url":"https://api.github.com/users/sravfeyn","html_url":"https://github.com/sravfeyn","followers_url":"https://api.github.com/users/sravfeyn/followers","following_url":"https://api.github.com/users/sravfeyn/following{/other_user}","gists_url":"https://api.github.com/users/sravfeyn/gists{/gist_id}","starred_url":"https://api.github.com/users/sravfeyn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sravfeyn/subscriptions","organizations_url":"https://api.github.com/users/sravfeyn/orgs","repos_url":"https://api.github.com/users/sravfeyn/repos","events_url":"https://api.github.com/users/sravfeyn/events{/privacy}","received_events_url":"https://api.github.com/users/sravfeyn/received_events","type":"User","site_admin":false},"body":"@snopoke This is a preliminary attempt to migrate synclogs to SQL. This is work in progress and there is still good amount of work left out. Does this look like a correct direction?","created_at":"2018-02-09T13:17:47Z","updated_at":"2018-03-06T06:14:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fdfc3201ceb216f5f25945c1d42c431e6054db52","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":79032211,"url":"https://api.github.com/repos/dimagi/commcare-hq/labels/Open%20for%20review:%20hold%20off%20on%20merge","name":"Open for review: hold off on merge","color":"5319e7","default":false},{"id":724787015,"url":"https://api.github.com/repos/dimagi/commcare-hq/labels/product/invisible","name":"product/invisible","color":"cfd2d6","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/dimagi/commcare-hq/pulls/19391/commits","review_comments_url":"https://api.github.com/repos/dimagi/commcare-hq/pulls/19391/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/19391/comments","statuses_url":"https://api.github.com/repos/dimagi/commcare-hq/statuses/7c761167ecc5d4dbf6223d0c01bb3086acf2004a","head":{"label":"dimagi:sr-pg-synclogs","ref":"sr-pg-synclogs","sha":"7c761167ecc5d4dbf6223d0c01bb3086acf2004a","user":{"login":"dimagi","id":94514,"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,"name":"commcare-hq","full_name":"dimagi/commcare-hq","owner":{"login":"dimagi","id":94514,"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-02-13T23:45:19Z","pushed_at":"2018-03-06T05:23:04Z","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":466971,"stargazers_count":86,"watchers_count":86,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":103,"mirror_url":null,"archived":false,"open_issues_count":84,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":103,"open_issues":84,"watchers":86,"default_branch":"master"}},"base":{"label":"dimagi:master","ref":"master","sha":"6c619fbb4db5298bf354218296cc7c80cc98e782","user":{"login":"dimagi","id":94514,"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,"name":"commcare-hq","full_name":"dimagi/commcare-hq","owner":{"login":"dimagi","id":94514,"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-02-13T23:45:19Z","pushed_at":"2018-03-06T05:23:04Z","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":466971,"stargazers_count":86,"watchers_count":86,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":103,"mirror_url":null,"archived":false,"open_issues_count":84,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":103,"open_issues":84,"watchers":86,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dimagi/commcare-hq/pulls/19391"},"html":{"href":"https://github.com/dimagi/commcare-hq/pull/19391"},"issue":{"href":"https://api.github.com/repos/dimagi/commcare-hq/issues/19391"},"comments":{"href":"https://api.github.com/repos/dimagi/commcare-hq/issues/19391/comments"},"review_comments":{"href":"https://api.github.com/repos/dimagi/commcare-hq/pulls/19391/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/19391/commits"},"statuses":{"href":"https://api.github.com/repos/dimagi/commcare-hq/statuses/7c761167ecc5d4dbf6223d0c01bb3086acf2004a"}},"author_association":"OWNER"}}
{"actor":{"display_login":"sravfeyn"}}