{"action":"created","comment":{"url":"https://api.github.com/repos/Recidiviz/recidiviz-data/pulls/comments/243064945","pull_request_review_id":186735398,"id":243064945,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI0MzA2NDk0NQ==","diff_hunk":"@@ -24,19 +26,199 @@ class EntityMatchingError(Exception):\n     pass\n \n \n-def get_entity_match(session, person):\n+# TODO(176): in Python 3, make these fields named and required\n+def is_person_match(person_a, person_b):\n     \"\"\"\n-    Queries the database to find all matching entities for the given Person.\n+    Given a database person and an ingested person, determine if they should be\n+    considered the same person.\n+    Args:\n+        person_a: (entities.Person)\n+        person_b: (entities.Person)\n+    Returns: (bool)\n+    \"\"\"\n+    if person_a.external_id or person_b.external_id:\n+        return person_a.external_id == person_b.external_id\n+\n+    # TODO(351): consider not matching if birthdate_inferred_from_age\n+\n+    if not all([person_a.given_names, person_b.given_names,","path":"recidiviz/persistence/entity_matching.py","position":null,"original_position":33,"commit_id":"5015be736adfb439598ee0ba603b10ac2efc5b67","original_commit_id":"1bc50952d8d014fb8b6daf84033148efe337bd8f","user":{"login":"jamwalla","id":1993708,"node_id":"MDQ6VXNlcjE5OTM3MDg=","avatar_url":"https://avatars2.githubusercontent.com/u/1993708?v=4","gravatar_id":"","url":"https://api.github.com/users/jamwalla","html_url":"https://github.com/jamwalla","followers_url":"https://api.github.com/users/jamwalla/followers","following_url":"https://api.github.com/users/jamwalla/following{/other_user}","gists_url":"https://api.github.com/users/jamwalla/gists{/gist_id}","starred_url":"https://api.github.com/users/jamwalla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jamwalla/subscriptions","organizations_url":"https://api.github.com/users/jamwalla/orgs","repos_url":"https://api.github.com/users/jamwalla/repos","events_url":"https://api.github.com/users/jamwalla/events{/privacy}","received_events_url":"https://api.github.com/users/jamwalla/received_events","type":"User","site_admin":false},"body":"no, I think we shouldn't match either way - maybe the converter shouldn't let empty strings get through to here, though. What do you think?","created_at":"2018-12-19T20:30:16Z","updated_at":"2018-12-19T20:30:16Z","html_url":"https://github.com/Recidiviz/recidiviz-data/pull/344#discussion_r243064945","pull_request_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/pulls/344","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/Recidiviz/recidiviz-data/pulls/comments/243064945"},"html":{"href":"https://github.com/Recidiviz/recidiviz-data/pull/344#discussion_r243064945"},"pull_request":{"href":"https://api.github.com/repos/Recidiviz/recidiviz-data/pulls/344"}},"in_reply_to_id":242981343},"pull_request":{"url":"https://api.github.com/repos/Recidiviz/recidiviz-data/pulls/344","id":239561036,"node_id":"MDExOlB1bGxSZXF1ZXN0MjM5NTYxMDM2","html_url":"https://github.com/Recidiviz/recidiviz-data/pull/344","diff_url":"https://github.com/Recidiviz/recidiviz-data/pull/344.diff","patch_url":"https://github.com/Recidiviz/recidiviz-data/pull/344.patch","issue_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/issues/344","number":344,"state":"open","locked":false,"title":"First take at entity matching","user":{"login":"terinpw","id":1114640,"node_id":"MDQ6VXNlcjExMTQ2NDA=","avatar_url":"https://avatars0.githubusercontent.com/u/1114640?v=4","gravatar_id":"","url":"https://api.github.com/users/terinpw","html_url":"https://github.com/terinpw","followers_url":"https://api.github.com/users/terinpw/followers","following_url":"https://api.github.com/users/terinpw/following{/other_user}","gists_url":"https://api.github.com/users/terinpw/gists{/gist_id}","starred_url":"https://api.github.com/users/terinpw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/terinpw/subscriptions","organizations_url":"https://api.github.com/users/terinpw/orgs","repos_url":"https://api.github.com/users/terinpw/repos","events_url":"https://api.github.com/users/terinpw/events{/privacy}","received_events_url":"https://api.github.com/users/terinpw/received_events","type":"User","site_admin":false},"body":"* Create db query to find people in a region with open bookings\r\n* Create basic entity equality methods for all entity types in entity_matching.py\r\n* Defined basic entity matching flow in entity_matching.match_entities \r\n* Added region to entities.Person (already in schema.Person)\r\n\r\nCaveats:\r\n- Assumes that the ingested entities passed into entity matching do not have inferred admission dates set. If the inferred dates are populated on the ingested entities some logic will need to change. \r\n- Only matches on People and Bookings for now (everything else in a follow up PR), but this means that old charges will be orphaned when a booking is re-scraped. \r\n\r\nCo-Authored-By: jamwalla","created_at":"2018-12-18T16:54:56Z","updated_at":"2018-12-19T20:30:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"510e9cbee6009b92fe23319227d8f3662ec045c9","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/pulls/344/commits","review_comments_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/pulls/344/comments","review_comment_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/issues/344/comments","statuses_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/statuses/5015be736adfb439598ee0ba603b10ac2efc5b67","head":{"label":"Recidiviz:entity_match_equality","ref":"entity_match_equality","sha":"5015be736adfb439598ee0ba603b10ac2efc5b67","user":{"login":"Recidiviz","id":35868122,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM1ODY4MTIy","avatar_url":"https://avatars2.githubusercontent.com/u/35868122?v=4","gravatar_id":"","url":"https://api.github.com/users/Recidiviz","html_url":"https://github.com/Recidiviz","followers_url":"https://api.github.com/users/Recidiviz/followers","following_url":"https://api.github.com/users/Recidiviz/following{/other_user}","gists_url":"https://api.github.com/users/Recidiviz/gists{/gist_id}","starred_url":"https://api.github.com/users/Recidiviz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Recidiviz/subscriptions","organizations_url":"https://api.github.com/users/Recidiviz/orgs","repos_url":"https://api.github.com/users/Recidiviz/repos","events_url":"https://api.github.com/users/Recidiviz/events{/privacy}","received_events_url":"https://api.github.com/users/Recidiviz/received_events","type":"Organization","site_admin":false},"repo":{"id":108306686,"node_id":"MDEwOlJlcG9zaXRvcnkxMDgzMDY2ODY=","name":"recidiviz-data","full_name":"Recidiviz/recidiviz-data","private":false,"owner":{"login":"Recidiviz","id":35868122,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM1ODY4MTIy","avatar_url":"https://avatars2.githubusercontent.com/u/35868122?v=4","gravatar_id":"","url":"https://api.github.com/users/Recidiviz","html_url":"https://github.com/Recidiviz","followers_url":"https://api.github.com/users/Recidiviz/followers","following_url":"https://api.github.com/users/Recidiviz/following{/other_user}","gists_url":"https://api.github.com/users/Recidiviz/gists{/gist_id}","starred_url":"https://api.github.com/users/Recidiviz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Recidiviz/subscriptions","organizations_url":"https://api.github.com/users/Recidiviz/orgs","repos_url":"https://api.github.com/users/Recidiviz/repos","events_url":"https://api.github.com/users/Recidiviz/events{/privacy}","received_events_url":"https://api.github.com/users/Recidiviz/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/Recidiviz/recidiviz-data","description":"Ingesting prison and jail records from various data sources and calculating criminal justice metrics","fork":false,"url":"https://api.github.com/repos/Recidiviz/recidiviz-data","forks_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/forks","keys_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/teams","hooks_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/hooks","issue_events_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/issues/events{/number}","events_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/events","assignees_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/assignees{/user}","branches_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/branches{/branch}","tags_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/tags","blobs_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/git/refs{/sha}","trees_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/statuses/{sha}","languages_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/languages","stargazers_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/stargazers","contributors_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/contributors","subscribers_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/subscribers","subscription_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/subscription","commits_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/commits{/sha}","git_commits_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/git/commits{/sha}","comments_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/comments{/number}","issue_comment_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/issues/comments{/number}","contents_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/contents/{+path}","compare_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/merges","archive_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/downloads","issues_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/issues{/number}","pulls_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/pulls{/number}","milestones_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/milestones{/number}","notifications_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/labels{/name}","releases_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/releases{/id}","deployments_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/deployments","created_at":"2017-10-25T18:04:59Z","updated_at":"2018-12-18T16:04:07Z","pushed_at":"2018-12-19T20:29:10Z","git_url":"git://github.com/Recidiviz/recidiviz-data.git","ssh_url":"git@github.com:Recidiviz/recidiviz-data.git","clone_url":"https://github.com/Recidiviz/recidiviz-data.git","svn_url":"https://github.com/Recidiviz/recidiviz-data","homepage":"","size":8651,"stargazers_count":8,"watchers_count":8,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"archived":false,"open_issues_count":95,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0","node_id":"MDc6TGljZW5zZTk="},"forks":9,"open_issues":95,"watchers":8,"default_branch":"master"}},"base":{"label":"Recidiviz:master","ref":"master","sha":"3d2d38e5daf12afc75991a234aeb7c7e57ba5570","user":{"login":"Recidiviz","id":35868122,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM1ODY4MTIy","avatar_url":"https://avatars2.githubusercontent.com/u/35868122?v=4","gravatar_id":"","url":"https://api.github.com/users/Recidiviz","html_url":"https://github.com/Recidiviz","followers_url":"https://api.github.com/users/Recidiviz/followers","following_url":"https://api.github.com/users/Recidiviz/following{/other_user}","gists_url":"https://api.github.com/users/Recidiviz/gists{/gist_id}","starred_url":"https://api.github.com/users/Recidiviz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Recidiviz/subscriptions","organizations_url":"https://api.github.com/users/Recidiviz/orgs","repos_url":"https://api.github.com/users/Recidiviz/repos","events_url":"https://api.github.com/users/Recidiviz/events{/privacy}","received_events_url":"https://api.github.com/users/Recidiviz/received_events","type":"Organization","site_admin":false},"repo":{"id":108306686,"node_id":"MDEwOlJlcG9zaXRvcnkxMDgzMDY2ODY=","name":"recidiviz-data","full_name":"Recidiviz/recidiviz-data","private":false,"owner":{"login":"Recidiviz","id":35868122,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM1ODY4MTIy","avatar_url":"https://avatars2.githubusercontent.com/u/35868122?v=4","gravatar_id":"","url":"https://api.github.com/users/Recidiviz","html_url":"https://github.com/Recidiviz","followers_url":"https://api.github.com/users/Recidiviz/followers","following_url":"https://api.github.com/users/Recidiviz/following{/other_user}","gists_url":"https://api.github.com/users/Recidiviz/gists{/gist_id}","starred_url":"https://api.github.com/users/Recidiviz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Recidiviz/subscriptions","organizations_url":"https://api.github.com/users/Recidiviz/orgs","repos_url":"https://api.github.com/users/Recidiviz/repos","events_url":"https://api.github.com/users/Recidiviz/events{/privacy}","received_events_url":"https://api.github.com/users/Recidiviz/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/Recidiviz/recidiviz-data","description":"Ingesting prison and jail records from various data sources and calculating criminal justice metrics","fork":false,"url":"https://api.github.com/repos/Recidiviz/recidiviz-data","forks_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/forks","keys_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/teams","hooks_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/hooks","issue_events_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/issues/events{/number}","events_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/events","assignees_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/assignees{/user}","branches_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/branches{/branch}","tags_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/tags","blobs_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/git/refs{/sha}","trees_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/statuses/{sha}","languages_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/languages","stargazers_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/stargazers","contributors_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/contributors","subscribers_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/subscribers","subscription_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/subscription","commits_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/commits{/sha}","git_commits_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/git/commits{/sha}","comments_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/comments{/number}","issue_comment_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/issues/comments{/number}","contents_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/contents/{+path}","compare_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/merges","archive_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/downloads","issues_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/issues{/number}","pulls_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/pulls{/number}","milestones_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/milestones{/number}","notifications_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/labels{/name}","releases_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/releases{/id}","deployments_url":"https://api.github.com/repos/Recidiviz/recidiviz-data/deployments","created_at":"2017-10-25T18:04:59Z","updated_at":"2018-12-18T16:04:07Z","pushed_at":"2018-12-19T20:29:10Z","git_url":"git://github.com/Recidiviz/recidiviz-data.git","ssh_url":"git@github.com:Recidiviz/recidiviz-data.git","clone_url":"https://github.com/Recidiviz/recidiviz-data.git","svn_url":"https://github.com/Recidiviz/recidiviz-data","homepage":"","size":8651,"stargazers_count":8,"watchers_count":8,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"archived":false,"open_issues_count":95,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0","node_id":"MDc6TGljZW5zZTk="},"forks":9,"open_issues":95,"watchers":8,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Recidiviz/recidiviz-data/pulls/344"},"html":{"href":"https://github.com/Recidiviz/recidiviz-data/pull/344"},"issue":{"href":"https://api.github.com/repos/Recidiviz/recidiviz-data/issues/344"},"comments":{"href":"https://api.github.com/repos/Recidiviz/recidiviz-data/issues/344/comments"},"review_comments":{"href":"https://api.github.com/repos/Recidiviz/recidiviz-data/pulls/344/comments"},"review_comment":{"href":"https://api.github.com/repos/Recidiviz/recidiviz-data/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Recidiviz/recidiviz-data/pulls/344/commits"},"statuses":{"href":"https://api.github.com/repos/Recidiviz/recidiviz-data/statuses/5015be736adfb439598ee0ba603b10ac2efc5b67"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"jamwalla"}}