{"action":"created","comment":{"url":"https://api.github.com/repos/aepyornis/hpd/pulls/comments/138340121","pull_request_review_id":62121144,"id":138340121,"diff_hunk":"@@ -0,0 +1,47 @@\n+-- One grand function to rule them all\n+-- This takes in a given bbl, and grabs the regid (btw there are more regids than bbls, so a bbl could have multiple regids?)\n+-- Using that, we use a few different functions that follow a (regid -> regids) convention\n+-- They use things like shared business addresses and fuzzy name lookup. This UNIONs those queries, merges them,\n+-- And then populates with relevant address info!\n+DROP FUNCTION IF EXISTS get_assoc_addrs_from_bbl(text);\n+\n+CREATE OR REPLACE FUNCTION get_assoc_addrs_from_bbl(_bbl text)\n+RETURNS TABLE (\n+  housenumber text,\n+  streetname text,\n+  boro text,\n+  zip text,\n+  lat numeric,\n+  lng numeric,\n+  regid int,\n+  bbl text,\n+  corpnames text[],\n+  businessaddrs text[],\n+  ownernames json\n+) AS $$\n+  SELECT\n+    housenumber,\n+    streetname,\n+    boro,\n+    zip,\n+    lat,\n+    lng,\n+    regid,\n+    bbl,\n+    corpnames,\n+    businessaddrs,\n+    ownernames\n+  FROM hpd_registrations_grouped_by_bbl_with_contacts AS r\n+  INNER JOIN (\n+    (SELECT DISTINCT registrationid FROM hpd_registrations_grouped_by_bbl_with_contacts r WHERE r.bbl = _bbl) userreg\n+    LEFT JOIN LATERAL","path":"sql/combined_search.sql","position":37,"original_position":37,"commit_id":"a7301c0a526d9495167217c230b53967f2148e3d","original_commit_id":"a7301c0a526d9495167217c230b53967f2148e3d","user":{"login":"aepyornis","id":8505044,"avatar_url":"https://avatars0.githubusercontent.com/u/8505044?v=4","gravatar_id":"","url":"https://api.github.com/users/aepyornis","html_url":"https://github.com/aepyornis","followers_url":"https://api.github.com/users/aepyornis/followers","following_url":"https://api.github.com/users/aepyornis/following{/other_user}","gists_url":"https://api.github.com/users/aepyornis/gists{/gist_id}","starred_url":"https://api.github.com/users/aepyornis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aepyornis/subscriptions","organizations_url":"https://api.github.com/users/aepyornis/orgs","repos_url":"https://api.github.com/users/aepyornis/repos","events_url":"https://api.github.com/users/aepyornis/events{/privacy}","received_events_url":"https://api.github.com/users/aepyornis/received_events","type":"User","site_admin":false},"body":"!!","created_at":"2017-09-12T13:02:59Z","updated_at":"2017-09-12T13:02:59Z","html_url":"https://github.com/aepyornis/hpd/pull/16#discussion_r138340121","pull_request_url":"https://api.github.com/repos/aepyornis/hpd/pulls/16","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/aepyornis/hpd/pulls/comments/138340121"},"html":{"href":"https://github.com/aepyornis/hpd/pull/16#discussion_r138340121"},"pull_request":{"href":"https://api.github.com/repos/aepyornis/hpd/pulls/16"}}},"pull_request":{"url":"https://api.github.com/repos/aepyornis/hpd/pulls/16","id":139910501,"html_url":"https://github.com/aepyornis/hpd/pull/16","diff_url":"https://github.com/aepyornis/hpd/pull/16.diff","patch_url":"https://github.com/aepyornis/hpd/pull/16.patch","issue_url":"https://api.github.com/repos/aepyornis/hpd/issues/16","number":16,"state":"open","locked":false,"title":"Expanding ownership mapping functions","user":{"login":"romeboards","id":627751,"avatar_url":"https://avatars2.githubusercontent.com/u/627751?v=4","gravatar_id":"","url":"https://api.github.com/users/romeboards","html_url":"https://github.com/romeboards","followers_url":"https://api.github.com/users/romeboards/followers","following_url":"https://api.github.com/users/romeboards/following{/other_user}","gists_url":"https://api.github.com/users/romeboards/gists{/gist_id}","starred_url":"https://api.github.com/users/romeboards/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/romeboards/subscriptions","organizations_url":"https://api.github.com/users/romeboards/orgs","repos_url":"https://api.github.com/users/romeboards/repos","events_url":"https://api.github.com/users/romeboards/events{/privacy}","received_events_url":"https://api.github.com/users/romeboards/received_events","type":"User","site_admin":false},"body":"These new functions establish a convention for working with multiple methods of ownership association, as well as a single overarching function that can combine all the methods together.\r\n\r\nThe convention for a single type of association is done as `regid -> regids`, i.e. input one registrationid and return any registrationids that might be associated given the particular method. This is now the convention in `sql/bisaddr_search.sql` and `sql/people_search.sql`.\r\n\r\nAll of this is brought together in `sql/combined_search.sql`, which unions multiple association methods and adds convenience translations to provide bbl -> regid -> regids -> addrs. The assumption (!) here is that even this very complex query is still more efficient than having to process multiple REST/AJAX calls to where the db is hosted.\r\n\r\n`sql/array_cat_agg.sql` provides a custom aggregate function that concatenates arrays without messy unnesting.\r\n\r\n","created_at":"2017-09-07T21:35:28Z","updated_at":"2017-09-12T13:02:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ba3584943a4fe03009808b5788cb2b054cf47990","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/aepyornis/hpd/pulls/16/commits","review_comments_url":"https://api.github.com/repos/aepyornis/hpd/pulls/16/comments","review_comment_url":"https://api.github.com/repos/aepyornis/hpd/pulls/comments{/number}","comments_url":"https://api.github.com/repos/aepyornis/hpd/issues/16/comments","statuses_url":"https://api.github.com/repos/aepyornis/hpd/statuses/a7301c0a526d9495167217c230b53967f2148e3d","head":{"label":"JustFixNYC:ownership","ref":"ownership","sha":"a7301c0a526d9495167217c230b53967f2148e3d","user":{"login":"JustFixNYC","id":18725617,"avatar_url":"https://avatars2.githubusercontent.com/u/18725617?v=4","gravatar_id":"","url":"https://api.github.com/users/JustFixNYC","html_url":"https://github.com/JustFixNYC","followers_url":"https://api.github.com/users/JustFixNYC/followers","following_url":"https://api.github.com/users/JustFixNYC/following{/other_user}","gists_url":"https://api.github.com/users/JustFixNYC/gists{/gist_id}","starred_url":"https://api.github.com/users/JustFixNYC/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JustFixNYC/subscriptions","organizations_url":"https://api.github.com/users/JustFixNYC/orgs","repos_url":"https://api.github.com/users/JustFixNYC/repos","events_url":"https://api.github.com/users/JustFixNYC/events{/privacy}","received_events_url":"https://api.github.com/users/JustFixNYC/received_events","type":"Organization","site_admin":false},"repo":{"id":98457892,"name":"hpd","full_name":"JustFixNYC/hpd","owner":{"login":"JustFixNYC","id":18725617,"avatar_url":"https://avatars2.githubusercontent.com/u/18725617?v=4","gravatar_id":"","url":"https://api.github.com/users/JustFixNYC","html_url":"https://github.com/JustFixNYC","followers_url":"https://api.github.com/users/JustFixNYC/followers","following_url":"https://api.github.com/users/JustFixNYC/following{/other_user}","gists_url":"https://api.github.com/users/JustFixNYC/gists{/gist_id}","starred_url":"https://api.github.com/users/JustFixNYC/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JustFixNYC/subscriptions","organizations_url":"https://api.github.com/users/JustFixNYC/orgs","repos_url":"https://api.github.com/users/JustFixNYC/repos","events_url":"https://api.github.com/users/JustFixNYC/events{/privacy}","received_events_url":"https://api.github.com/users/JustFixNYC/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/JustFixNYC/hpd","description":"Large Corporate Landlords Hidden in HPD data","fork":true,"url":"https://api.github.com/repos/JustFixNYC/hpd","forks_url":"https://api.github.com/repos/JustFixNYC/hpd/forks","keys_url":"https://api.github.com/repos/JustFixNYC/hpd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/JustFixNYC/hpd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/JustFixNYC/hpd/teams","hooks_url":"https://api.github.com/repos/JustFixNYC/hpd/hooks","issue_events_url":"https://api.github.com/repos/JustFixNYC/hpd/issues/events{/number}","events_url":"https://api.github.com/repos/JustFixNYC/hpd/events","assignees_url":"https://api.github.com/repos/JustFixNYC/hpd/assignees{/user}","branches_url":"https://api.github.com/repos/JustFixNYC/hpd/branches{/branch}","tags_url":"https://api.github.com/repos/JustFixNYC/hpd/tags","blobs_url":"https://api.github.com/repos/JustFixNYC/hpd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/JustFixNYC/hpd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/JustFixNYC/hpd/git/refs{/sha}","trees_url":"https://api.github.com/repos/JustFixNYC/hpd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/JustFixNYC/hpd/statuses/{sha}","languages_url":"https://api.github.com/repos/JustFixNYC/hpd/languages","stargazers_url":"https://api.github.com/repos/JustFixNYC/hpd/stargazers","contributors_url":"https://api.github.com/repos/JustFixNYC/hpd/contributors","subscribers_url":"https://api.github.com/repos/JustFixNYC/hpd/subscribers","subscription_url":"https://api.github.com/repos/JustFixNYC/hpd/subscription","commits_url":"https://api.github.com/repos/JustFixNYC/hpd/commits{/sha}","git_commits_url":"https://api.github.com/repos/JustFixNYC/hpd/git/commits{/sha}","comments_url":"https://api.github.com/repos/JustFixNYC/hpd/comments{/number}","issue_comment_url":"https://api.github.com/repos/JustFixNYC/hpd/issues/comments{/number}","contents_url":"https://api.github.com/repos/JustFixNYC/hpd/contents/{+path}","compare_url":"https://api.github.com/repos/JustFixNYC/hpd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/JustFixNYC/hpd/merges","archive_url":"https://api.github.com/repos/JustFixNYC/hpd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/JustFixNYC/hpd/downloads","issues_url":"https://api.github.com/repos/JustFixNYC/hpd/issues{/number}","pulls_url":"https://api.github.com/repos/JustFixNYC/hpd/pulls{/number}","milestones_url":"https://api.github.com/repos/JustFixNYC/hpd/milestones{/number}","notifications_url":"https://api.github.com/repos/JustFixNYC/hpd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/JustFixNYC/hpd/labels{/name}","releases_url":"https://api.github.com/repos/JustFixNYC/hpd/releases{/id}","deployments_url":"https://api.github.com/repos/JustFixNYC/hpd/deployments","created_at":"2017-07-26T19:19:59Z","updated_at":"2017-07-26T19:20:01Z","pushed_at":"2017-09-07T21:24:51Z","git_url":"git://github.com/JustFixNYC/hpd.git","ssh_url":"git@github.com:JustFixNYC/hpd.git","clone_url":"https://github.com/JustFixNYC/hpd.git","svn_url":"https://github.com/JustFixNYC/hpd","homepage":"https://hpd.ziggy.space","size":27366,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"aepyornis:master","ref":"master","sha":"ceb707fe10fe365fbfe750ccf228740538c50379","user":{"login":"aepyornis","id":8505044,"avatar_url":"https://avatars0.githubusercontent.com/u/8505044?v=4","gravatar_id":"","url":"https://api.github.com/users/aepyornis","html_url":"https://github.com/aepyornis","followers_url":"https://api.github.com/users/aepyornis/followers","following_url":"https://api.github.com/users/aepyornis/following{/other_user}","gists_url":"https://api.github.com/users/aepyornis/gists{/gist_id}","starred_url":"https://api.github.com/users/aepyornis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aepyornis/subscriptions","organizations_url":"https://api.github.com/users/aepyornis/orgs","repos_url":"https://api.github.com/users/aepyornis/repos","events_url":"https://api.github.com/users/aepyornis/events{/privacy}","received_events_url":"https://api.github.com/users/aepyornis/received_events","type":"User","site_admin":false},"repo":{"id":43906434,"name":"hpd","full_name":"aepyornis/hpd","owner":{"login":"aepyornis","id":8505044,"avatar_url":"https://avatars0.githubusercontent.com/u/8505044?v=4","gravatar_id":"","url":"https://api.github.com/users/aepyornis","html_url":"https://github.com/aepyornis","followers_url":"https://api.github.com/users/aepyornis/followers","following_url":"https://api.github.com/users/aepyornis/following{/other_user}","gists_url":"https://api.github.com/users/aepyornis/gists{/gist_id}","starred_url":"https://api.github.com/users/aepyornis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aepyornis/subscriptions","organizations_url":"https://api.github.com/users/aepyornis/orgs","repos_url":"https://api.github.com/users/aepyornis/repos","events_url":"https://api.github.com/users/aepyornis/events{/privacy}","received_events_url":"https://api.github.com/users/aepyornis/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/aepyornis/hpd","description":"Large Corporate Landlords Hidden in HPD data","fork":false,"url":"https://api.github.com/repos/aepyornis/hpd","forks_url":"https://api.github.com/repos/aepyornis/hpd/forks","keys_url":"https://api.github.com/repos/aepyornis/hpd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aepyornis/hpd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aepyornis/hpd/teams","hooks_url":"https://api.github.com/repos/aepyornis/hpd/hooks","issue_events_url":"https://api.github.com/repos/aepyornis/hpd/issues/events{/number}","events_url":"https://api.github.com/repos/aepyornis/hpd/events","assignees_url":"https://api.github.com/repos/aepyornis/hpd/assignees{/user}","branches_url":"https://api.github.com/repos/aepyornis/hpd/branches{/branch}","tags_url":"https://api.github.com/repos/aepyornis/hpd/tags","blobs_url":"https://api.github.com/repos/aepyornis/hpd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aepyornis/hpd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aepyornis/hpd/git/refs{/sha}","trees_url":"https://api.github.com/repos/aepyornis/hpd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aepyornis/hpd/statuses/{sha}","languages_url":"https://api.github.com/repos/aepyornis/hpd/languages","stargazers_url":"https://api.github.com/repos/aepyornis/hpd/stargazers","contributors_url":"https://api.github.com/repos/aepyornis/hpd/contributors","subscribers_url":"https://api.github.com/repos/aepyornis/hpd/subscribers","subscription_url":"https://api.github.com/repos/aepyornis/hpd/subscription","commits_url":"https://api.github.com/repos/aepyornis/hpd/commits{/sha}","git_commits_url":"https://api.github.com/repos/aepyornis/hpd/git/commits{/sha}","comments_url":"https://api.github.com/repos/aepyornis/hpd/comments{/number}","issue_comment_url":"https://api.github.com/repos/aepyornis/hpd/issues/comments{/number}","contents_url":"https://api.github.com/repos/aepyornis/hpd/contents/{+path}","compare_url":"https://api.github.com/repos/aepyornis/hpd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aepyornis/hpd/merges","archive_url":"https://api.github.com/repos/aepyornis/hpd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aepyornis/hpd/downloads","issues_url":"https://api.github.com/repos/aepyornis/hpd/issues{/number}","pulls_url":"https://api.github.com/repos/aepyornis/hpd/pulls{/number}","milestones_url":"https://api.github.com/repos/aepyornis/hpd/milestones{/number}","notifications_url":"https://api.github.com/repos/aepyornis/hpd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aepyornis/hpd/labels{/name}","releases_url":"https://api.github.com/repos/aepyornis/hpd/releases{/id}","deployments_url":"https://api.github.com/repos/aepyornis/hpd/deployments","created_at":"2015-10-08T17:45:20Z","updated_at":"2017-07-24T17:40:02Z","pushed_at":"2017-09-07T21:35:29Z","git_url":"git://github.com/aepyornis/hpd.git","ssh_url":"git@github.com:aepyornis/hpd.git","clone_url":"https://github.com/aepyornis/hpd.git","svn_url":"https://github.com/aepyornis/hpd","homepage":"https://hpd.ziggy.space","size":27362,"stargazers_count":7,"watchers_count":7,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":5,"forks":6,"open_issues":5,"watchers":7,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/aepyornis/hpd/pulls/16"},"html":{"href":"https://github.com/aepyornis/hpd/pull/16"},"issue":{"href":"https://api.github.com/repos/aepyornis/hpd/issues/16"},"comments":{"href":"https://api.github.com/repos/aepyornis/hpd/issues/16/comments"},"review_comments":{"href":"https://api.github.com/repos/aepyornis/hpd/pulls/16/comments"},"review_comment":{"href":"https://api.github.com/repos/aepyornis/hpd/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/aepyornis/hpd/pulls/16/commits"},"statuses":{"href":"https://api.github.com/repos/aepyornis/hpd/statuses/a7301c0a526d9495167217c230b53967f2148e3d"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"aepyornis"}}