{"action":"created","comment":{"url":"https://api.github.com/repos/resolvetosavelives/redapp-server/pulls/comments/187145154","pull_request_review_id":118865368,"id":187145154,"diff_hunk":"@@ -0,0 +1,22 @@\n+module MergeRecord\n+\n+  # make this an ActiveSupport::Concern ?\n+\n+  def self.merge(model, where_clauses, record)\n+    existing_record = model.find_by(where_clauses)\n+    if existing_record.nil?\n+      model.create(where_clauses.merge(record))\n+    else\n+      if record[:updated_at] > existing_record.updated_at\n+        existing_record.update(record)\n+      end\n+      existing_record\n+    end\n+  end\n+\n+  def self.bulk_merge_on_id(model, records)","path":"app/helpers/merge_record.rb","position":17,"original_position":17,"commit_id":"7a3a75dbacdb9686082c7bc542fc8dc5f45a9117","original_commit_id":"7a3a75dbacdb9686082c7bc542fc8dc5f45a9117","user":{"login":"timcheadle","id":612212,"avatar_url":"https://avatars2.githubusercontent.com/u/612212?v=4","gravatar_id":"","url":"https://api.github.com/users/timcheadle","html_url":"https://github.com/timcheadle","followers_url":"https://api.github.com/users/timcheadle/followers","following_url":"https://api.github.com/users/timcheadle/following{/other_user}","gists_url":"https://api.github.com/users/timcheadle/gists{/gist_id}","starred_url":"https://api.github.com/users/timcheadle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timcheadle/subscriptions","organizations_url":"https://api.github.com/users/timcheadle/orgs","repos_url":"https://api.github.com/users/timcheadle/repos","events_url":"https://api.github.com/users/timcheadle/events{/privacy}","received_events_url":"https://api.github.com/users/timcheadle/received_events","type":"User","site_admin":false},"body":"I think calling it `records` is confusing here when really it's an array of param hashes.","created_at":"2018-05-09T19:08:49Z","updated_at":"2018-05-09T19:28:36Z","html_url":"https://github.com/resolvetosavelives/redapp-server/pull/1#discussion_r187145154","pull_request_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/pulls/1","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/resolvetosavelives/redapp-server/pulls/comments/187145154"},"html":{"href":"https://github.com/resolvetosavelives/redapp-server/pull/1#discussion_r187145154"},"pull_request":{"href":"https://api.github.com/repos/resolvetosavelives/redapp-server/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/resolvetosavelives/redapp-server/pulls/1","id":186915424,"html_url":"https://github.com/resolvetosavelives/redapp-server/pull/1","diff_url":"https://github.com/resolvetosavelives/redapp-server/pull/1.diff","patch_url":"https://github.com/resolvetosavelives/redapp-server/pull/1.patch","issue_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/issues/1","number":1,"state":"open","locked":false,"title":"[WIP] Sync patients","user":{"login":"govindkrjoshi","id":3933133,"avatar_url":"https://avatars0.githubusercontent.com/u/3933133?v=4","gravatar_id":"","url":"https://api.github.com/users/govindkrjoshi","html_url":"https://github.com/govindkrjoshi","followers_url":"https://api.github.com/users/govindkrjoshi/followers","following_url":"https://api.github.com/users/govindkrjoshi/following{/other_user}","gists_url":"https://api.github.com/users/govindkrjoshi/gists{/gist_id}","starred_url":"https://api.github.com/users/govindkrjoshi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/govindkrjoshi/subscriptions","organizations_url":"https://api.github.com/users/govindkrjoshi/orgs","repos_url":"https://api.github.com/users/govindkrjoshi/repos","events_url":"https://api.github.com/users/govindkrjoshi/events{/privacy}","received_events_url":"https://api.github.com/users/govindkrjoshi/received_events","type":"User","site_admin":false},"body":"This PR should not be merged as is, is only here for visibility\r\n\r\n- First cut of syncing patients from users\r\n- Sending back data to users isn't done yet\r\n- The merging logic itself is fairly generically applicable to all entities. We'll refine this with time.\r\n\r\n-- \r\nSrihari and Govind","created_at":"2018-05-09T13:04:35Z","updated_at":"2018-05-09T19:28:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"95479f3a7abb2317993b749a06362bd3faedaf8e","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/pulls/1/commits","review_comments_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/pulls/1/comments","review_comment_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/pulls/comments{/number}","comments_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/issues/1/comments","statuses_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/statuses/7a3a75dbacdb9686082c7bc542fc8dc5f45a9117","head":{"label":"resolvetosavelives:sync-patients","ref":"sync-patients","sha":"7a3a75dbacdb9686082c7bc542fc8dc5f45a9117","user":{"login":"resolvetosavelives","id":38174283,"avatar_url":"https://avatars0.githubusercontent.com/u/38174283?v=4","gravatar_id":"","url":"https://api.github.com/users/resolvetosavelives","html_url":"https://github.com/resolvetosavelives","followers_url":"https://api.github.com/users/resolvetosavelives/followers","following_url":"https://api.github.com/users/resolvetosavelives/following{/other_user}","gists_url":"https://api.github.com/users/resolvetosavelives/gists{/gist_id}","starred_url":"https://api.github.com/users/resolvetosavelives/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/resolvetosavelives/subscriptions","organizations_url":"https://api.github.com/users/resolvetosavelives/orgs","repos_url":"https://api.github.com/users/resolvetosavelives/repos","events_url":"https://api.github.com/users/resolvetosavelives/events{/privacy}","received_events_url":"https://api.github.com/users/resolvetosavelives/received_events","type":"Organization","site_admin":false},"repo":{"id":132516184,"name":"redapp-server","full_name":"resolvetosavelives/redapp-server","owner":{"login":"resolvetosavelives","id":38174283,"avatar_url":"https://avatars0.githubusercontent.com/u/38174283?v=4","gravatar_id":"","url":"https://api.github.com/users/resolvetosavelives","html_url":"https://github.com/resolvetosavelives","followers_url":"https://api.github.com/users/resolvetosavelives/followers","following_url":"https://api.github.com/users/resolvetosavelives/following{/other_user}","gists_url":"https://api.github.com/users/resolvetosavelives/gists{/gist_id}","starred_url":"https://api.github.com/users/resolvetosavelives/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/resolvetosavelives/subscriptions","organizations_url":"https://api.github.com/users/resolvetosavelives/orgs","repos_url":"https://api.github.com/users/resolvetosavelives/repos","events_url":"https://api.github.com/users/resolvetosavelives/events{/privacy}","received_events_url":"https://api.github.com/users/resolvetosavelives/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/resolvetosavelives/redapp-server","description":"A Rails backend to support the RedApp mobile app","fork":false,"url":"https://api.github.com/repos/resolvetosavelives/redapp-server","forks_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/forks","keys_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/teams","hooks_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/hooks","issue_events_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/issues/events{/number}","events_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/events","assignees_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/assignees{/user}","branches_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/branches{/branch}","tags_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/tags","blobs_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/statuses/{sha}","languages_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/languages","stargazers_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/stargazers","contributors_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/contributors","subscribers_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/subscribers","subscription_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/subscription","commits_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/contents/{+path}","compare_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/merges","archive_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/downloads","issues_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/issues{/number}","pulls_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/pulls{/number}","milestones_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/milestones{/number}","notifications_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/labels{/name}","releases_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/releases{/id}","deployments_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/deployments","created_at":"2018-05-07T21:03:09Z","updated_at":"2018-05-07T21:25:39Z","pushed_at":"2018-05-09T13:04:36Z","git_url":"git://github.com/resolvetosavelives/redapp-server.git","ssh_url":"git@github.com:resolvetosavelives/redapp-server.git","clone_url":"https://github.com/resolvetosavelives/redapp-server.git","svn_url":"https://github.com/resolvetosavelives/redapp-server","homepage":null,"size":37,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"resolvetosavelives:master","ref":"master","sha":"11be7906e75d02092921cc8934b80958297db828","user":{"login":"resolvetosavelives","id":38174283,"avatar_url":"https://avatars0.githubusercontent.com/u/38174283?v=4","gravatar_id":"","url":"https://api.github.com/users/resolvetosavelives","html_url":"https://github.com/resolvetosavelives","followers_url":"https://api.github.com/users/resolvetosavelives/followers","following_url":"https://api.github.com/users/resolvetosavelives/following{/other_user}","gists_url":"https://api.github.com/users/resolvetosavelives/gists{/gist_id}","starred_url":"https://api.github.com/users/resolvetosavelives/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/resolvetosavelives/subscriptions","organizations_url":"https://api.github.com/users/resolvetosavelives/orgs","repos_url":"https://api.github.com/users/resolvetosavelives/repos","events_url":"https://api.github.com/users/resolvetosavelives/events{/privacy}","received_events_url":"https://api.github.com/users/resolvetosavelives/received_events","type":"Organization","site_admin":false},"repo":{"id":132516184,"name":"redapp-server","full_name":"resolvetosavelives/redapp-server","owner":{"login":"resolvetosavelives","id":38174283,"avatar_url":"https://avatars0.githubusercontent.com/u/38174283?v=4","gravatar_id":"","url":"https://api.github.com/users/resolvetosavelives","html_url":"https://github.com/resolvetosavelives","followers_url":"https://api.github.com/users/resolvetosavelives/followers","following_url":"https://api.github.com/users/resolvetosavelives/following{/other_user}","gists_url":"https://api.github.com/users/resolvetosavelives/gists{/gist_id}","starred_url":"https://api.github.com/users/resolvetosavelives/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/resolvetosavelives/subscriptions","organizations_url":"https://api.github.com/users/resolvetosavelives/orgs","repos_url":"https://api.github.com/users/resolvetosavelives/repos","events_url":"https://api.github.com/users/resolvetosavelives/events{/privacy}","received_events_url":"https://api.github.com/users/resolvetosavelives/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/resolvetosavelives/redapp-server","description":"A Rails backend to support the RedApp mobile app","fork":false,"url":"https://api.github.com/repos/resolvetosavelives/redapp-server","forks_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/forks","keys_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/teams","hooks_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/hooks","issue_events_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/issues/events{/number}","events_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/events","assignees_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/assignees{/user}","branches_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/branches{/branch}","tags_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/tags","blobs_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/statuses/{sha}","languages_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/languages","stargazers_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/stargazers","contributors_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/contributors","subscribers_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/subscribers","subscription_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/subscription","commits_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/contents/{+path}","compare_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/merges","archive_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/downloads","issues_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/issues{/number}","pulls_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/pulls{/number}","milestones_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/milestones{/number}","notifications_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/labels{/name}","releases_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/releases{/id}","deployments_url":"https://api.github.com/repos/resolvetosavelives/redapp-server/deployments","created_at":"2018-05-07T21:03:09Z","updated_at":"2018-05-07T21:25:39Z","pushed_at":"2018-05-09T13:04:36Z","git_url":"git://github.com/resolvetosavelives/redapp-server.git","ssh_url":"git@github.com:resolvetosavelives/redapp-server.git","clone_url":"https://github.com/resolvetosavelives/redapp-server.git","svn_url":"https://github.com/resolvetosavelives/redapp-server","homepage":null,"size":37,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/resolvetosavelives/redapp-server/pulls/1"},"html":{"href":"https://github.com/resolvetosavelives/redapp-server/pull/1"},"issue":{"href":"https://api.github.com/repos/resolvetosavelives/redapp-server/issues/1"},"comments":{"href":"https://api.github.com/repos/resolvetosavelives/redapp-server/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/resolvetosavelives/redapp-server/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/resolvetosavelives/redapp-server/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/resolvetosavelives/redapp-server/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/resolvetosavelives/redapp-server/statuses/7a3a75dbacdb9686082c7bc542fc8dc5f45a9117"}},"author_association":"NONE"}}
{"actor":{"display_login":"timcheadle"}}