{"action":"created","comment":{"url":"https://api.github.com/repos/pg-irc/pathways-backend/pulls/comments/170274619","pull_request_review_id":98921249,"id":170274619,"diff_hunk":"@@ -110,17 +111,84 @@ def test_has_physical_address(self):\n     def test_has_postal_address(self):\n         self.location_has_address_of_type('postal_address')\n \n-    def test_has_point(self):\n+    def test_has_point_values(self):\n         point = Point(a_float(), a_float())\n         LocationBuilder(self.organization).with_point(point).create()\n         url = '/v1/locations/'\n         response = self.client.get(url)\n-        self.assertEqual(response.json()[0]['point'], point.__str__())\n+        self.assertEqual(response.json()[0]['latitude'], point.x)\n+        self.assertEqual(response.json()[0]['longitude'], point.y)\n \n-    def test_point_value_instantiates_to_geos_geometry(self):\n+    def test_point_values_instantiate_a_point(self):\n         LocationBuilder(self.organization).create()\n         url = '/v1/locations/'\n         response = self.client.get(url)\n-        # This will throw one of a few various exceptions\n-        # if parsing the value fails\n-        GEOSGeometry(response.json()[0]['point'])\n+        # This will throw one of a few various exceptions (causing test failure)\n+        # if parsing the values fails\n+        latitude = float(response.json()[0]['latitude'])\n+        longitude = float(response.json()[0]['longitude'])\n+        Point(latitude, longitude)\n+\n+class ServiceAtLocationProximityFilterTests(rest_test.APITestCase):\n+    def setUp(self):\n+        self.organization = OrganizationBuilder().create()\n+        self.service = ServiceBuilder(self.organization).create()\n+\n+    def test_200_response_when_proximity_includes_plus(self):\n+        url = '/v1/services_at_location/?proximity=+11.1111,+222.2222'\n+        response = self.client.get(url)\n+        self.assertEqual(response.status_code, status.HTTP_200_OK)\n+\n+    def test_200_response_when_proximity_excludes_plus(self):\n+        url = '/v1/services_at_location/?proximity=11.1111,-222.2222'\n+        response = self.client.get(url)\n+        self.assertEqual(response.status_code, status.HTTP_200_OK)\n+\n+    def test_400_response_when_proximity_has_one_value(self):\n+        url = '/v1/services_at_location/?proximity=+11.1111'\n+        response = self.client.get(url)\n+        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)\n+\n+    def test_400_response_when_proximity_has_more_than_two_values(self):\n+        url = '/v1/services_at_location/?proximity=+11.1111,-222.2222,333.3333'\n+        response = self.client.get(url)\n+        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)\n+\n+    def test_400_response_when_proximity_uses_none_comma_separator(self):\n+        url = '/v1/services_at_location/?proximity=+11.1111&-222.2222'\n+        response = self.client.get(url)\n+        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)\n+\n+    def test_400_response_when_proximity_to_cannot_represent_a_point(self):\n+        url = '/v1/services_at_location/?proximity=foo,bar'\n+        response = self.client.get(url)\n+        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)\n+\n+    def test_can_order_by_proximity(self):\n+        vancouver_location = (LocationBuilder(self.organization)\n+                              .with_name('Vancouver')\n+                              .with_point(Point(49.246292, -123.116226)).create())\n+        chilliwack_location = (LocationBuilder(self.organization)\n+                              .with_name('Chilliwack')\n+                              .with_point(Point(49.157940, -121.951467)).create())\n+        kamloops_location = (LocationBuilder(self.organization)\n+                              .with_name('Kamloops')\n+                              .with_point(Point(50.674522, -120.327268)).create())\n+        salmon_arm_location = (LocationBuilder(self.organization)\n+                              .with_name('Salmon Arm')\n+                              .with_point(Point(50.700103, -119.283844)).create())","path":"human_services/locations/tests/test_api.py","position":94,"original_position":88,"commit_id":"54a540efef60db3b4b4b2e4ed17e985d51edcb36","original_commit_id":"9bb33835193df2ab80c3faa807196fde02641851","user":{"login":"rasmus-storjohann-PG","id":32307781,"avatar_url":"https://avatars0.githubusercontent.com/u/32307781?v=4","gravatar_id":"","url":"https://api.github.com/users/rasmus-storjohann-PG","html_url":"https://github.com/rasmus-storjohann-PG","followers_url":"https://api.github.com/users/rasmus-storjohann-PG/followers","following_url":"https://api.github.com/users/rasmus-storjohann-PG/following{/other_user}","gists_url":"https://api.github.com/users/rasmus-storjohann-PG/gists{/gist_id}","starred_url":"https://api.github.com/users/rasmus-storjohann-PG/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rasmus-storjohann-PG/subscriptions","organizations_url":"https://api.github.com/users/rasmus-storjohann-PG/orgs","repos_url":"https://api.github.com/users/rasmus-storjohann-PG/repos","events_url":"https://api.github.com/users/rasmus-storjohann-PG/events{/privacy}","received_events_url":"https://api.github.com/users/rasmus-storjohann-PG/received_events","type":"User","site_admin":false},"body":"I like this test a lot. One thing that would make it easier to follow for someone not familiar with BC geography would be, probably jumble them up so that you can show that the sort is actually doing something and not just returning them in their order of creation, or you can use third_location as your target.\r\n```\r\n        first_location = (LocationBuilder(self.organization)\r\n                              .with_name('First')\r\n                              .with_point(Point(0, 0)).create())\r\n        second_location = (LocationBuilder(self.organization)\r\n                              .with_name('Second')\r\n                              .with_point(Point(10, 10)).create())\r\n        third_location = (LocationBuilder(self.organization)\r\n                              .with_name('Third')\r\n                              .with_point(Point(25, 25)).create())\r\n        fourth_location = (LocationBuilder(self.organization)\r\n                              .with_name('Fourth')\r\n                              .with_point(Point(30, 30)).create())\r\n```\r\nI know, it's not as fun, but it is easier to follow, especially since I can look at the latlongs and be able to tell easily what the correct ordering ought to be","created_at":"2018-02-23T15:05:09Z","updated_at":"2018-02-23T15:19:25Z","html_url":"https://github.com/pg-irc/pathways-backend/pull/195#discussion_r170274619","pull_request_url":"https://api.github.com/repos/pg-irc/pathways-backend/pulls/195","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/pg-irc/pathways-backend/pulls/comments/170274619"},"html":{"href":"https://github.com/pg-irc/pathways-backend/pull/195#discussion_r170274619"},"pull_request":{"href":"https://api.github.com/repos/pg-irc/pathways-backend/pulls/195"}}},"pull_request":{"url":"https://api.github.com/repos/pg-irc/pathways-backend/pulls/195","id":170626321,"html_url":"https://github.com/pg-irc/pathways-backend/pull/195","diff_url":"https://github.com/pg-irc/pathways-backend/pull/195.diff","patch_url":"https://github.com/pg-irc/pathways-backend/pull/195.patch","issue_url":"https://api.github.com/repos/pg-irc/pathways-backend/issues/195","number":195,"state":"open","locked":false,"title":"Feature/issue 170 Proximity based sorting","user":{"login":"bensinjin","id":3228323,"avatar_url":"https://avatars2.githubusercontent.com/u/3228323?v=4","gravatar_id":"","url":"https://api.github.com/users/bensinjin","html_url":"https://github.com/bensinjin","followers_url":"https://api.github.com/users/bensinjin/followers","following_url":"https://api.github.com/users/bensinjin/following{/other_user}","gists_url":"https://api.github.com/users/bensinjin/gists{/gist_id}","starred_url":"https://api.github.com/users/bensinjin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bensinjin/subscriptions","organizations_url":"https://api.github.com/users/bensinjin/orgs","repos_url":"https://api.github.com/users/bensinjin/repos","events_url":"https://api.github.com/users/bensinjin/events{/privacy}","received_events_url":"https://api.github.com/users/bensinjin/received_events","type":"User","site_admin":false},"body":"So here we have where I'm currently at with the proximity sorting piece. The initial commits are all around enforcing Postgres with PostGIS as our database layer and cleaning up configuration and documentation around using the .env file locally. There are a couple commits related to getting Travis playing nice with PostGIS that took some fiddling, it probably was not the best strategy to test if Travis builds pass by pushing to the branch but in this case getting it working wasn't too bad. Mixed in with this work I also migrate lat long float fields to Point objects, a requirement for our proximity searches. \r\n\r\nThe latter half of the commits are around creating the filter required to sort by proximity. I've opted to create a base filter class called BaseProximityFilter and extend it for our pathways specific endpoints. I've taken this approach because our db layer in order to perform the distance query needs to know how to get a Point value from an object in a given queryset, I don't want to have to hardcode values specific to our ServiceAtLocation objects. You can see our specific ServiceAtLocation implementation here: https://github.com/pg-irc/pathways-backend/commit/4f1d3bc37b9847183b7105d88d428caeb5234ad2#diff-709ccfbc293eccc22a3f1981b8ed5322R78.\r\n\r\nAnyways this is still a WIP just wanted to keep you up to speed.","created_at":"2018-02-22T00:25:09Z","updated_at":"2018-02-23T15:19:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2572ba0a30f1d755c9f02f40ea86b31888e0e15a","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/pg-irc/pathways-backend/pulls/195/commits","review_comments_url":"https://api.github.com/repos/pg-irc/pathways-backend/pulls/195/comments","review_comment_url":"https://api.github.com/repos/pg-irc/pathways-backend/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pg-irc/pathways-backend/issues/195/comments","statuses_url":"https://api.github.com/repos/pg-irc/pathways-backend/statuses/54a540efef60db3b4b4b2e4ed17e985d51edcb36","head":{"label":"pg-irc:feature/issue_170","ref":"feature/issue_170","sha":"54a540efef60db3b4b4b2e4ed17e985d51edcb36","user":{"login":"pg-irc","id":30124065,"avatar_url":"https://avatars3.githubusercontent.com/u/30124065?v=4","gravatar_id":"","url":"https://api.github.com/users/pg-irc","html_url":"https://github.com/pg-irc","followers_url":"https://api.github.com/users/pg-irc/followers","following_url":"https://api.github.com/users/pg-irc/following{/other_user}","gists_url":"https://api.github.com/users/pg-irc/gists{/gist_id}","starred_url":"https://api.github.com/users/pg-irc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pg-irc/subscriptions","organizations_url":"https://api.github.com/users/pg-irc/orgs","repos_url":"https://api.github.com/users/pg-irc/repos","events_url":"https://api.github.com/users/pg-irc/events{/privacy}","received_events_url":"https://api.github.com/users/pg-irc/received_events","type":"Organization","site_admin":false},"repo":{"id":98336819,"name":"pathways-backend","full_name":"pg-irc/pathways-backend","owner":{"login":"pg-irc","id":30124065,"avatar_url":"https://avatars3.githubusercontent.com/u/30124065?v=4","gravatar_id":"","url":"https://api.github.com/users/pg-irc","html_url":"https://github.com/pg-irc","followers_url":"https://api.github.com/users/pg-irc/followers","following_url":"https://api.github.com/users/pg-irc/following{/other_user}","gists_url":"https://api.github.com/users/pg-irc/gists{/gist_id}","starred_url":"https://api.github.com/users/pg-irc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pg-irc/subscriptions","organizations_url":"https://api.github.com/users/pg-irc/orgs","repos_url":"https://api.github.com/users/pg-irc/repos","events_url":"https://api.github.com/users/pg-irc/events{/privacy}","received_events_url":"https://api.github.com/users/pg-irc/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pg-irc/pathways-backend","description":null,"fork":false,"url":"https://api.github.com/repos/pg-irc/pathways-backend","forks_url":"https://api.github.com/repos/pg-irc/pathways-backend/forks","keys_url":"https://api.github.com/repos/pg-irc/pathways-backend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pg-irc/pathways-backend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pg-irc/pathways-backend/teams","hooks_url":"https://api.github.com/repos/pg-irc/pathways-backend/hooks","issue_events_url":"https://api.github.com/repos/pg-irc/pathways-backend/issues/events{/number}","events_url":"https://api.github.com/repos/pg-irc/pathways-backend/events","assignees_url":"https://api.github.com/repos/pg-irc/pathways-backend/assignees{/user}","branches_url":"https://api.github.com/repos/pg-irc/pathways-backend/branches{/branch}","tags_url":"https://api.github.com/repos/pg-irc/pathways-backend/tags","blobs_url":"https://api.github.com/repos/pg-irc/pathways-backend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pg-irc/pathways-backend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pg-irc/pathways-backend/git/refs{/sha}","trees_url":"https://api.github.com/repos/pg-irc/pathways-backend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pg-irc/pathways-backend/statuses/{sha}","languages_url":"https://api.github.com/repos/pg-irc/pathways-backend/languages","stargazers_url":"https://api.github.com/repos/pg-irc/pathways-backend/stargazers","contributors_url":"https://api.github.com/repos/pg-irc/pathways-backend/contributors","subscribers_url":"https://api.github.com/repos/pg-irc/pathways-backend/subscribers","subscription_url":"https://api.github.com/repos/pg-irc/pathways-backend/subscription","commits_url":"https://api.github.com/repos/pg-irc/pathways-backend/commits{/sha}","git_commits_url":"https://api.github.com/repos/pg-irc/pathways-backend/git/commits{/sha}","comments_url":"https://api.github.com/repos/pg-irc/pathways-backend/comments{/number}","issue_comment_url":"https://api.github.com/repos/pg-irc/pathways-backend/issues/comments{/number}","contents_url":"https://api.github.com/repos/pg-irc/pathways-backend/contents/{+path}","compare_url":"https://api.github.com/repos/pg-irc/pathways-backend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pg-irc/pathways-backend/merges","archive_url":"https://api.github.com/repos/pg-irc/pathways-backend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pg-irc/pathways-backend/downloads","issues_url":"https://api.github.com/repos/pg-irc/pathways-backend/issues{/number}","pulls_url":"https://api.github.com/repos/pg-irc/pathways-backend/pulls{/number}","milestones_url":"https://api.github.com/repos/pg-irc/pathways-backend/milestones{/number}","notifications_url":"https://api.github.com/repos/pg-irc/pathways-backend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pg-irc/pathways-backend/labels{/name}","releases_url":"https://api.github.com/repos/pg-irc/pathways-backend/releases{/id}","deployments_url":"https://api.github.com/repos/pg-irc/pathways-backend/deployments","created_at":"2017-07-25T18:18:26Z","updated_at":"2017-11-21T23:53:47Z","pushed_at":"2018-02-22T22:25:27Z","git_url":"git://github.com/pg-irc/pathways-backend.git","ssh_url":"git@github.com:pg-irc/pathways-backend.git","clone_url":"https://github.com/pg-irc/pathways-backend.git","svn_url":"https://github.com/pg-irc/pathways-backend","homepage":null,"size":1031,"stargazers_count":5,"watchers_count":5,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"archived":false,"open_issues_count":79,"license":{"key":"bsd-3-clause","name":"BSD 3-Clause \"New\" or \"Revised\" License","spdx_id":"BSD-3-Clause","url":"https://api.github.com/licenses/bsd-3-clause"},"forks":3,"open_issues":79,"watchers":5,"default_branch":"master"}},"base":{"label":"pg-irc:master","ref":"master","sha":"d2269e30d241fcfbeda35ed7a1cbb5556c37aa3c","user":{"login":"pg-irc","id":30124065,"avatar_url":"https://avatars3.githubusercontent.com/u/30124065?v=4","gravatar_id":"","url":"https://api.github.com/users/pg-irc","html_url":"https://github.com/pg-irc","followers_url":"https://api.github.com/users/pg-irc/followers","following_url":"https://api.github.com/users/pg-irc/following{/other_user}","gists_url":"https://api.github.com/users/pg-irc/gists{/gist_id}","starred_url":"https://api.github.com/users/pg-irc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pg-irc/subscriptions","organizations_url":"https://api.github.com/users/pg-irc/orgs","repos_url":"https://api.github.com/users/pg-irc/repos","events_url":"https://api.github.com/users/pg-irc/events{/privacy}","received_events_url":"https://api.github.com/users/pg-irc/received_events","type":"Organization","site_admin":false},"repo":{"id":98336819,"name":"pathways-backend","full_name":"pg-irc/pathways-backend","owner":{"login":"pg-irc","id":30124065,"avatar_url":"https://avatars3.githubusercontent.com/u/30124065?v=4","gravatar_id":"","url":"https://api.github.com/users/pg-irc","html_url":"https://github.com/pg-irc","followers_url":"https://api.github.com/users/pg-irc/followers","following_url":"https://api.github.com/users/pg-irc/following{/other_user}","gists_url":"https://api.github.com/users/pg-irc/gists{/gist_id}","starred_url":"https://api.github.com/users/pg-irc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pg-irc/subscriptions","organizations_url":"https://api.github.com/users/pg-irc/orgs","repos_url":"https://api.github.com/users/pg-irc/repos","events_url":"https://api.github.com/users/pg-irc/events{/privacy}","received_events_url":"https://api.github.com/users/pg-irc/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pg-irc/pathways-backend","description":null,"fork":false,"url":"https://api.github.com/repos/pg-irc/pathways-backend","forks_url":"https://api.github.com/repos/pg-irc/pathways-backend/forks","keys_url":"https://api.github.com/repos/pg-irc/pathways-backend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pg-irc/pathways-backend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pg-irc/pathways-backend/teams","hooks_url":"https://api.github.com/repos/pg-irc/pathways-backend/hooks","issue_events_url":"https://api.github.com/repos/pg-irc/pathways-backend/issues/events{/number}","events_url":"https://api.github.com/repos/pg-irc/pathways-backend/events","assignees_url":"https://api.github.com/repos/pg-irc/pathways-backend/assignees{/user}","branches_url":"https://api.github.com/repos/pg-irc/pathways-backend/branches{/branch}","tags_url":"https://api.github.com/repos/pg-irc/pathways-backend/tags","blobs_url":"https://api.github.com/repos/pg-irc/pathways-backend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pg-irc/pathways-backend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pg-irc/pathways-backend/git/refs{/sha}","trees_url":"https://api.github.com/repos/pg-irc/pathways-backend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pg-irc/pathways-backend/statuses/{sha}","languages_url":"https://api.github.com/repos/pg-irc/pathways-backend/languages","stargazers_url":"https://api.github.com/repos/pg-irc/pathways-backend/stargazers","contributors_url":"https://api.github.com/repos/pg-irc/pathways-backend/contributors","subscribers_url":"https://api.github.com/repos/pg-irc/pathways-backend/subscribers","subscription_url":"https://api.github.com/repos/pg-irc/pathways-backend/subscription","commits_url":"https://api.github.com/repos/pg-irc/pathways-backend/commits{/sha}","git_commits_url":"https://api.github.com/repos/pg-irc/pathways-backend/git/commits{/sha}","comments_url":"https://api.github.com/repos/pg-irc/pathways-backend/comments{/number}","issue_comment_url":"https://api.github.com/repos/pg-irc/pathways-backend/issues/comments{/number}","contents_url":"https://api.github.com/repos/pg-irc/pathways-backend/contents/{+path}","compare_url":"https://api.github.com/repos/pg-irc/pathways-backend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pg-irc/pathways-backend/merges","archive_url":"https://api.github.com/repos/pg-irc/pathways-backend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pg-irc/pathways-backend/downloads","issues_url":"https://api.github.com/repos/pg-irc/pathways-backend/issues{/number}","pulls_url":"https://api.github.com/repos/pg-irc/pathways-backend/pulls{/number}","milestones_url":"https://api.github.com/repos/pg-irc/pathways-backend/milestones{/number}","notifications_url":"https://api.github.com/repos/pg-irc/pathways-backend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pg-irc/pathways-backend/labels{/name}","releases_url":"https://api.github.com/repos/pg-irc/pathways-backend/releases{/id}","deployments_url":"https://api.github.com/repos/pg-irc/pathways-backend/deployments","created_at":"2017-07-25T18:18:26Z","updated_at":"2017-11-21T23:53:47Z","pushed_at":"2018-02-22T22:25:27Z","git_url":"git://github.com/pg-irc/pathways-backend.git","ssh_url":"git@github.com:pg-irc/pathways-backend.git","clone_url":"https://github.com/pg-irc/pathways-backend.git","svn_url":"https://github.com/pg-irc/pathways-backend","homepage":null,"size":1031,"stargazers_count":5,"watchers_count":5,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"archived":false,"open_issues_count":79,"license":{"key":"bsd-3-clause","name":"BSD 3-Clause \"New\" or \"Revised\" License","spdx_id":"BSD-3-Clause","url":"https://api.github.com/licenses/bsd-3-clause"},"forks":3,"open_issues":79,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pg-irc/pathways-backend/pulls/195"},"html":{"href":"https://github.com/pg-irc/pathways-backend/pull/195"},"issue":{"href":"https://api.github.com/repos/pg-irc/pathways-backend/issues/195"},"comments":{"href":"https://api.github.com/repos/pg-irc/pathways-backend/issues/195/comments"},"review_comments":{"href":"https://api.github.com/repos/pg-irc/pathways-backend/pulls/195/comments"},"review_comment":{"href":"https://api.github.com/repos/pg-irc/pathways-backend/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pg-irc/pathways-backend/pulls/195/commits"},"statuses":{"href":"https://api.github.com/repos/pg-irc/pathways-backend/statuses/54a540efef60db3b4b4b2e4ed17e985d51edcb36"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"rasmus-storjohann-PG"}}