{"action":"created","comment":{"url":"https://api.github.com/repos/artsy/metaphysics/pulls/comments/244388495","pull_request_review_id":188353154,"id":244388495,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI0NDM4ODQ5NQ==","diff_hunk":"@@ -0,0 +1,43 @@\n+interface LatLng {\n+  lat: number\n+  lng: number\n+}\n+\n+const EARTH_RADIUS_IN_METERS = 6371e3 // https://en.wikipedia.org/wiki/Earth_radius#Mean_radius\n+\n+/**\n+ * Convert angular distance from degrees to radians\n+ *\n+ * @param {number} degrees - decimal degrees\n+ * @returns {number} radians\n+ */\n+const toRadians = (degrees: number): number => degrees * (Math.PI / 180)\n+\n+/**\n+ * Calculates the haversine (spherical) distance between two geographic points.\n+ * Arguments are supplied as `LatLng` objects, with coordinates specified\n+ * as `lat` and `lng` properties in decimal degrees.\n+ *\n+ * See:\n+ * https://en.wikipedia.org/wiki/Haversine_formula\n+ * https://www.movable-type.co.uk/scripts/latlong.html\n+ *\n+ * @param {LatLng} point1 - an object with `lat` and `lng` properties\n+ * @param {LatLng} point2 - an object with `lat` and `lng` properties\n+ * @returns {number} Distance between point1 and point2, in meters\n+ */\n+const haversineDistance = (point1: LatLng, point2: LatLng): number => {\n+  const φ1 = toRadians(point1.lat)\n+  const φ2 = toRadians(point2.lat)\n+  const Δφ = toRadians(point2.lat - point1.lat)\n+  const Δλ = toRadians(point2.lng - point1.lng)","path":"src/lib/geospatial.ts","position":42,"original_position":33,"commit_id":"97140414cd57d595905b066fd48417cde0227522","original_commit_id":"2e7fe5e0ff2670a4858ab3e5dd57bde2003ef9c2","user":{"login":"alloy","id":2320,"node_id":"MDQ6VXNlcjIzMjA=","avatar_url":"https://avatars2.githubusercontent.com/u/2320?v=4","gravatar_id":"","url":"https://api.github.com/users/alloy","html_url":"https://github.com/alloy","followers_url":"https://api.github.com/users/alloy/followers","following_url":"https://api.github.com/users/alloy/following{/other_user}","gists_url":"https://api.github.com/users/alloy/gists{/gist_id}","starred_url":"https://api.github.com/users/alloy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alloy/subscriptions","organizations_url":"https://api.github.com/users/alloy/orgs","repos_url":"https://api.github.com/users/alloy/repos","events_url":"https://api.github.com/users/alloy/events{/privacy}","received_events_url":"https://api.github.com/users/alloy/received_events","type":"User","site_admin":false},"body":"I'm ok with a bit of an artful touch 🎨, especially in a pace that will likely only be worked on by people that know this domain.","created_at":"2018-12-28T19:14:21Z","updated_at":"2018-12-28T19:14:22Z","html_url":"https://github.com/artsy/metaphysics/pull/1448#discussion_r244388495","pull_request_url":"https://api.github.com/repos/artsy/metaphysics/pulls/1448","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/artsy/metaphysics/pulls/comments/244388495"},"html":{"href":"https://github.com/artsy/metaphysics/pull/1448#discussion_r244388495"},"pull_request":{"href":"https://api.github.com/repos/artsy/metaphysics/pulls/1448"}},"in_reply_to_id":244222321},"pull_request":{"url":"https://api.github.com/repos/artsy/metaphysics/pulls/1448","id":241220474,"node_id":"MDExOlB1bGxSZXF1ZXN0MjQxMjIwNDc0","html_url":"https://github.com/artsy/metaphysics/pull/1448","diff_url":"https://github.com/artsy/metaphysics/pull/1448.diff","patch_url":"https://github.com/artsy/metaphysics/pull/1448.patch","issue_url":"https://api.github.com/repos/artsy/metaphysics/issues/1448","number":1448,"state":"open","locked":false,"title":"Allow finding a local discovery city nearest to an arbitrary point","user":{"login":"anandaroop","id":140521,"node_id":"MDQ6VXNlcjE0MDUyMQ==","avatar_url":"https://avatars1.githubusercontent.com/u/140521?v=4","gravatar_id":"","url":"https://api.github.com/users/anandaroop","html_url":"https://github.com/anandaroop","followers_url":"https://api.github.com/users/anandaroop/followers","following_url":"https://api.github.com/users/anandaroop/following{/other_user}","gists_url":"https://api.github.com/users/anandaroop/gists{/gist_id}","starred_url":"https://api.github.com/users/anandaroop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anandaroop/subscriptions","organizations_url":"https://api.github.com/users/anandaroop/orgs","repos_url":"https://api.github.com/users/anandaroop/repos","events_url":"https://api.github.com/users/anandaroop/events{/privacy}","received_events_url":"https://api.github.com/users/anandaroop/received_events","type":"User","site_admin":false},"body":"Implements: https://artsyproduct.atlassian.net/browse/LD-64\r\nFollow-up to: https://github.com/artsy/emission/pull/1252#discussion_r243255869\r\n\r\nThis allows a client to find a local discovery city by latititude/longitude, as obtained e.g. via a device's geolocation API.\r\n\r\nTo do this we modify the root `city` query to allow lookup by lat/lng (in addition to the already implemented lookup by slug).\r\n\r\nThe lat/lng lookup is subject to a threshold, such that if you supply a point close enough to an existing city you will get a result:\r\n\r\n![found](https://user-images.githubusercontent.com/140521/50493427-6a7c3400-09eb-11e9-810f-83783f880c9e.png)\r\n\r\nBut if you supply a point not close enough, you will get `null`:\r\n\r\n![null](https://user-images.githubusercontent.com/140521/50493432-6f40e800-09eb-11e9-8e74-0bc43caef4f7.png)\r\n\r\nIn the Emission thread we discussed having this query return the city if an appropriate one is found, or else `null` or something representing _no city found_. I've modeled this as a simple `null` for now but am open to suggestion, if that is not idiomatic GraphQL.","created_at":"2018-12-27T20:39:44Z","updated_at":"2018-12-28T19:14:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9b744212017263040f6b88945cc8abe67fa0e2d3","assignee":{"login":"alloy","id":2320,"node_id":"MDQ6VXNlcjIzMjA=","avatar_url":"https://avatars2.githubusercontent.com/u/2320?v=4","gravatar_id":"","url":"https://api.github.com/users/alloy","html_url":"https://github.com/alloy","followers_url":"https://api.github.com/users/alloy/followers","following_url":"https://api.github.com/users/alloy/following{/other_user}","gists_url":"https://api.github.com/users/alloy/gists{/gist_id}","starred_url":"https://api.github.com/users/alloy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alloy/subscriptions","organizations_url":"https://api.github.com/users/alloy/orgs","repos_url":"https://api.github.com/users/alloy/repos","events_url":"https://api.github.com/users/alloy/events{/privacy}","received_events_url":"https://api.github.com/users/alloy/received_events","type":"User","site_admin":false},"assignees":[{"login":"alloy","id":2320,"node_id":"MDQ6VXNlcjIzMjA=","avatar_url":"https://avatars2.githubusercontent.com/u/2320?v=4","gravatar_id":"","url":"https://api.github.com/users/alloy","html_url":"https://github.com/alloy","followers_url":"https://api.github.com/users/alloy/followers","following_url":"https://api.github.com/users/alloy/following{/other_user}","gists_url":"https://api.github.com/users/alloy/gists{/gist_id}","starred_url":"https://api.github.com/users/alloy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alloy/subscriptions","organizations_url":"https://api.github.com/users/alloy/orgs","repos_url":"https://api.github.com/users/alloy/repos","events_url":"https://api.github.com/users/alloy/events{/privacy}","received_events_url":"https://api.github.com/users/alloy/received_events","type":"User","site_admin":false}],"requested_reviewers":[{"login":"l2succes","id":296775,"node_id":"MDQ6VXNlcjI5Njc3NQ==","avatar_url":"https://avatars0.githubusercontent.com/u/296775?v=4","gravatar_id":"","url":"https://api.github.com/users/l2succes","html_url":"https://github.com/l2succes","followers_url":"https://api.github.com/users/l2succes/followers","following_url":"https://api.github.com/users/l2succes/following{/other_user}","gists_url":"https://api.github.com/users/l2succes/gists{/gist_id}","starred_url":"https://api.github.com/users/l2succes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/l2succes/subscriptions","organizations_url":"https://api.github.com/users/l2succes/orgs","repos_url":"https://api.github.com/users/l2succes/repos","events_url":"https://api.github.com/users/l2succes/events{/privacy}","received_events_url":"https://api.github.com/users/l2succes/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[{"id":1093508051,"node_id":"MDU6TGFiZWwxMDkzNTA4MDUx","url":"https://api.github.com/repos/artsy/metaphysics/labels/Jira%20Synced","name":"Jira Synced","color":"0366d6","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/artsy/metaphysics/pulls/1448/commits","review_comments_url":"https://api.github.com/repos/artsy/metaphysics/pulls/1448/comments","review_comment_url":"https://api.github.com/repos/artsy/metaphysics/pulls/comments{/number}","comments_url":"https://api.github.com/repos/artsy/metaphysics/issues/1448/comments","statuses_url":"https://api.github.com/repos/artsy/metaphysics/statuses/97140414cd57d595905b066fd48417cde0227522","head":{"label":"anandaroop:nearest-city","ref":"nearest-city","sha":"97140414cd57d595905b066fd48417cde0227522","user":{"login":"anandaroop","id":140521,"node_id":"MDQ6VXNlcjE0MDUyMQ==","avatar_url":"https://avatars1.githubusercontent.com/u/140521?v=4","gravatar_id":"","url":"https://api.github.com/users/anandaroop","html_url":"https://github.com/anandaroop","followers_url":"https://api.github.com/users/anandaroop/followers","following_url":"https://api.github.com/users/anandaroop/following{/other_user}","gists_url":"https://api.github.com/users/anandaroop/gists{/gist_id}","starred_url":"https://api.github.com/users/anandaroop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anandaroop/subscriptions","organizations_url":"https://api.github.com/users/anandaroop/orgs","repos_url":"https://api.github.com/users/anandaroop/repos","events_url":"https://api.github.com/users/anandaroop/events{/privacy}","received_events_url":"https://api.github.com/users/anandaroop/received_events","type":"User","site_admin":false},"repo":{"id":90071398,"node_id":"MDEwOlJlcG9zaXRvcnk5MDA3MTM5OA==","name":"metaphysics","full_name":"anandaroop/metaphysics","private":false,"owner":{"login":"anandaroop","id":140521,"node_id":"MDQ6VXNlcjE0MDUyMQ==","avatar_url":"https://avatars1.githubusercontent.com/u/140521?v=4","gravatar_id":"","url":"https://api.github.com/users/anandaroop","html_url":"https://github.com/anandaroop","followers_url":"https://api.github.com/users/anandaroop/followers","following_url":"https://api.github.com/users/anandaroop/following{/other_user}","gists_url":"https://api.github.com/users/anandaroop/gists{/gist_id}","starred_url":"https://api.github.com/users/anandaroop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anandaroop/subscriptions","organizations_url":"https://api.github.com/users/anandaroop/orgs","repos_url":"https://api.github.com/users/anandaroop/repos","events_url":"https://api.github.com/users/anandaroop/events{/privacy}","received_events_url":"https://api.github.com/users/anandaroop/received_events","type":"User","site_admin":false},"html_url":"https://github.com/anandaroop/metaphysics","description":"Artsy's GraphQL API","fork":true,"url":"https://api.github.com/repos/anandaroop/metaphysics","forks_url":"https://api.github.com/repos/anandaroop/metaphysics/forks","keys_url":"https://api.github.com/repos/anandaroop/metaphysics/keys{/key_id}","collaborators_url":"https://api.github.com/repos/anandaroop/metaphysics/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/anandaroop/metaphysics/teams","hooks_url":"https://api.github.com/repos/anandaroop/metaphysics/hooks","issue_events_url":"https://api.github.com/repos/anandaroop/metaphysics/issues/events{/number}","events_url":"https://api.github.com/repos/anandaroop/metaphysics/events","assignees_url":"https://api.github.com/repos/anandaroop/metaphysics/assignees{/user}","branches_url":"https://api.github.com/repos/anandaroop/metaphysics/branches{/branch}","tags_url":"https://api.github.com/repos/anandaroop/metaphysics/tags","blobs_url":"https://api.github.com/repos/anandaroop/metaphysics/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/anandaroop/metaphysics/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/anandaroop/metaphysics/git/refs{/sha}","trees_url":"https://api.github.com/repos/anandaroop/metaphysics/git/trees{/sha}","statuses_url":"https://api.github.com/repos/anandaroop/metaphysics/statuses/{sha}","languages_url":"https://api.github.com/repos/anandaroop/metaphysics/languages","stargazers_url":"https://api.github.com/repos/anandaroop/metaphysics/stargazers","contributors_url":"https://api.github.com/repos/anandaroop/metaphysics/contributors","subscribers_url":"https://api.github.com/repos/anandaroop/metaphysics/subscribers","subscription_url":"https://api.github.com/repos/anandaroop/metaphysics/subscription","commits_url":"https://api.github.com/repos/anandaroop/metaphysics/commits{/sha}","git_commits_url":"https://api.github.com/repos/anandaroop/metaphysics/git/commits{/sha}","comments_url":"https://api.github.com/repos/anandaroop/metaphysics/comments{/number}","issue_comment_url":"https://api.github.com/repos/anandaroop/metaphysics/issues/comments{/number}","contents_url":"https://api.github.com/repos/anandaroop/metaphysics/contents/{+path}","compare_url":"https://api.github.com/repos/anandaroop/metaphysics/compare/{base}...{head}","merges_url":"https://api.github.com/repos/anandaroop/metaphysics/merges","archive_url":"https://api.github.com/repos/anandaroop/metaphysics/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/anandaroop/metaphysics/downloads","issues_url":"https://api.github.com/repos/anandaroop/metaphysics/issues{/number}","pulls_url":"https://api.github.com/repos/anandaroop/metaphysics/pulls{/number}","milestones_url":"https://api.github.com/repos/anandaroop/metaphysics/milestones{/number}","notifications_url":"https://api.github.com/repos/anandaroop/metaphysics/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/anandaroop/metaphysics/labels{/name}","releases_url":"https://api.github.com/repos/anandaroop/metaphysics/releases{/id}","deployments_url":"https://api.github.com/repos/anandaroop/metaphysics/deployments","created_at":"2017-05-02T19:43:21Z","updated_at":"2018-12-18T15:08:01Z","pushed_at":"2018-12-28T16:15:18Z","git_url":"git://github.com/anandaroop/metaphysics.git","ssh_url":"git@github.com:anandaroop/metaphysics.git","clone_url":"https://github.com/anandaroop/metaphysics.git","svn_url":"https://github.com/anandaroop/metaphysics","homepage":"","size":7351,"stargazers_count":0,"watchers_count":0,"language":"TypeScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"artsy:master","ref":"master","sha":"20b27b343ca809a9c2f88b329423f9a86e1d27b0","user":{"login":"artsy","id":546231,"node_id":"MDEyOk9yZ2FuaXphdGlvbjU0NjIzMQ==","avatar_url":"https://avatars3.githubusercontent.com/u/546231?v=4","gravatar_id":"","url":"https://api.github.com/users/artsy","html_url":"https://github.com/artsy","followers_url":"https://api.github.com/users/artsy/followers","following_url":"https://api.github.com/users/artsy/following{/other_user}","gists_url":"https://api.github.com/users/artsy/gists{/gist_id}","starred_url":"https://api.github.com/users/artsy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/artsy/subscriptions","organizations_url":"https://api.github.com/users/artsy/orgs","repos_url":"https://api.github.com/users/artsy/repos","events_url":"https://api.github.com/users/artsy/events{/privacy}","received_events_url":"https://api.github.com/users/artsy/received_events","type":"Organization","site_admin":false},"repo":{"id":42728510,"node_id":"MDEwOlJlcG9zaXRvcnk0MjcyODUxMA==","name":"metaphysics","full_name":"artsy/metaphysics","private":false,"owner":{"login":"artsy","id":546231,"node_id":"MDEyOk9yZ2FuaXphdGlvbjU0NjIzMQ==","avatar_url":"https://avatars3.githubusercontent.com/u/546231?v=4","gravatar_id":"","url":"https://api.github.com/users/artsy","html_url":"https://github.com/artsy","followers_url":"https://api.github.com/users/artsy/followers","following_url":"https://api.github.com/users/artsy/following{/other_user}","gists_url":"https://api.github.com/users/artsy/gists{/gist_id}","starred_url":"https://api.github.com/users/artsy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/artsy/subscriptions","organizations_url":"https://api.github.com/users/artsy/orgs","repos_url":"https://api.github.com/users/artsy/repos","events_url":"https://api.github.com/users/artsy/events{/privacy}","received_events_url":"https://api.github.com/users/artsy/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/artsy/metaphysics","description":"Artsy's GraphQL API","fork":false,"url":"https://api.github.com/repos/artsy/metaphysics","forks_url":"https://api.github.com/repos/artsy/metaphysics/forks","keys_url":"https://api.github.com/repos/artsy/metaphysics/keys{/key_id}","collaborators_url":"https://api.github.com/repos/artsy/metaphysics/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/artsy/metaphysics/teams","hooks_url":"https://api.github.com/repos/artsy/metaphysics/hooks","issue_events_url":"https://api.github.com/repos/artsy/metaphysics/issues/events{/number}","events_url":"https://api.github.com/repos/artsy/metaphysics/events","assignees_url":"https://api.github.com/repos/artsy/metaphysics/assignees{/user}","branches_url":"https://api.github.com/repos/artsy/metaphysics/branches{/branch}","tags_url":"https://api.github.com/repos/artsy/metaphysics/tags","blobs_url":"https://api.github.com/repos/artsy/metaphysics/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/artsy/metaphysics/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/artsy/metaphysics/git/refs{/sha}","trees_url":"https://api.github.com/repos/artsy/metaphysics/git/trees{/sha}","statuses_url":"https://api.github.com/repos/artsy/metaphysics/statuses/{sha}","languages_url":"https://api.github.com/repos/artsy/metaphysics/languages","stargazers_url":"https://api.github.com/repos/artsy/metaphysics/stargazers","contributors_url":"https://api.github.com/repos/artsy/metaphysics/contributors","subscribers_url":"https://api.github.com/repos/artsy/metaphysics/subscribers","subscription_url":"https://api.github.com/repos/artsy/metaphysics/subscription","commits_url":"https://api.github.com/repos/artsy/metaphysics/commits{/sha}","git_commits_url":"https://api.github.com/repos/artsy/metaphysics/git/commits{/sha}","comments_url":"https://api.github.com/repos/artsy/metaphysics/comments{/number}","issue_comment_url":"https://api.github.com/repos/artsy/metaphysics/issues/comments{/number}","contents_url":"https://api.github.com/repos/artsy/metaphysics/contents/{+path}","compare_url":"https://api.github.com/repos/artsy/metaphysics/compare/{base}...{head}","merges_url":"https://api.github.com/repos/artsy/metaphysics/merges","archive_url":"https://api.github.com/repos/artsy/metaphysics/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/artsy/metaphysics/downloads","issues_url":"https://api.github.com/repos/artsy/metaphysics/issues{/number}","pulls_url":"https://api.github.com/repos/artsy/metaphysics/pulls{/number}","milestones_url":"https://api.github.com/repos/artsy/metaphysics/milestones{/number}","notifications_url":"https://api.github.com/repos/artsy/metaphysics/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/artsy/metaphysics/labels{/name}","releases_url":"https://api.github.com/repos/artsy/metaphysics/releases{/id}","deployments_url":"https://api.github.com/repos/artsy/metaphysics/deployments","created_at":"2015-09-18T14:51:48Z","updated_at":"2018-12-28T14:48:33Z","pushed_at":"2018-12-28T16:15:19Z","git_url":"git://github.com/artsy/metaphysics.git","ssh_url":"git@github.com:artsy/metaphysics.git","clone_url":"https://github.com/artsy/metaphysics.git","svn_url":"https://github.com/artsy/metaphysics","homepage":"","size":7560,"stargazers_count":196,"watchers_count":196,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":55,"mirror_url":null,"archived":false,"open_issues_count":54,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":55,"open_issues":54,"watchers":196,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/artsy/metaphysics/pulls/1448"},"html":{"href":"https://github.com/artsy/metaphysics/pull/1448"},"issue":{"href":"https://api.github.com/repos/artsy/metaphysics/issues/1448"},"comments":{"href":"https://api.github.com/repos/artsy/metaphysics/issues/1448/comments"},"review_comments":{"href":"https://api.github.com/repos/artsy/metaphysics/pulls/1448/comments"},"review_comment":{"href":"https://api.github.com/repos/artsy/metaphysics/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/artsy/metaphysics/pulls/1448/commits"},"statuses":{"href":"https://api.github.com/repos/artsy/metaphysics/statuses/97140414cd57d595905b066fd48417cde0227522"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"alloy"}}