{"action":"created","comment":{"url":"https://api.github.com/repos/nhsuk/nearby-services-api/pulls/comments/91906082","pull_request_review_id":12413966,"id":91906082,"diff_hunk":"@@ -7,31 +7,34 @@ function getPharmacies(req, res, next) {\n   req.checkQuery('longitude', 'longitude is required').notEmpty();\n   req.checkQuery('latitude', 'latitude must be between -90 and 90').isFloat({ min: -90, max: 90 });\n   req.checkQuery('longitude', 'longitude must be between -180 and 180').isFloat({ min: -180, max: 180 });\n+  req.checkQuery('limits:results:open', 'limits:results:open must be a number between 1 and 3').optional().isInt({ min: 1, max: 3 });\n+  req.checkQuery('limits:results:nearby', 'limits:results:nearby must be a number between 1 and 10').optional().isInt({ min: 1, max: 10 });\n \n   const errors = req.validationErrors();\n \n   if (errors) {\n     log.warn(errors, 'getPharmacies errors');\n     res.status(400).json(errors);\n+  } else {\n+    const latitude = req.query.latitude;\n+    const longitude = req.query.longitude;\n+    const nearby = req.query['limits:results:nearby'] || 3;\n+    const open = req.query['limits:results:open'] || 1;\n+    // Given how search performance is impacted by the radius of the search\n+    // it has intentionaly not been allowed to be specificed by the client\n+    const searchRadius = 20;","path":"app/middleware/getPharmacies.js","position":19,"original_position":19,"commit_id":"6b177774d3663c82ef51785af3a8e411b43877de","original_commit_id":"6b177774d3663c82ef51785af3a8e411b43877de","user":{"login":"neilbmclaughlin","id":212582,"avatar_url":"https://avatars.githubusercontent.com/u/212582?v=3","gravatar_id":"","url":"https://api.github.com/users/neilbmclaughlin","html_url":"https://github.com/neilbmclaughlin","followers_url":"https://api.github.com/users/neilbmclaughlin/followers","following_url":"https://api.github.com/users/neilbmclaughlin/following{/other_user}","gists_url":"https://api.github.com/users/neilbmclaughlin/gists{/gist_id}","starred_url":"https://api.github.com/users/neilbmclaughlin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/neilbmclaughlin/subscriptions","organizations_url":"https://api.github.com/users/neilbmclaughlin/orgs","repos_url":"https://api.github.com/users/neilbmclaughlin/repos","events_url":"https://api.github.com/users/neilbmclaughlin/events{/privacy}","received_events_url":"https://api.github.com/users/neilbmclaughlin/received_events","type":"User","site_admin":false},"body":"Might be worth relaxing this in future so the searchRadius is passed as a parameter but is validated to be less than some system configurable value.","created_at":"2016-12-12T09:06:24Z","updated_at":"2016-12-12T09:29:51Z","html_url":"https://github.com/nhsuk/nearby-services-api/pull/21#discussion_r91906082","pull_request_url":"https://api.github.com/repos/nhsuk/nearby-services-api/pulls/21","_links":{"self":{"href":"https://api.github.com/repos/nhsuk/nearby-services-api/pulls/comments/91906082"},"html":{"href":"https://github.com/nhsuk/nearby-services-api/pull/21#discussion_r91906082"},"pull_request":{"href":"https://api.github.com/repos/nhsuk/nearby-services-api/pulls/21"}}},"pull_request":{"url":"https://api.github.com/repos/nhsuk/nearby-services-api/pulls/21","id":97152083,"html_url":"https://github.com/nhsuk/nearby-services-api/pull/21","diff_url":"https://github.com/nhsuk/nearby-services-api/pull/21.diff","patch_url":"https://github.com/nhsuk/nearby-services-api/pull/21.patch","issue_url":"https://api.github.com/repos/nhsuk/nearby-services-api/issues/21","number":21,"state":"open","locked":false,"title":":rewind::fast_forward: Allow result limits to be set by client","user":{"login":"st3v3nhunt","id":639706,"avatar_url":"https://avatars.githubusercontent.com/u/639706?v=3","gravatar_id":"","url":"https://api.github.com/users/st3v3nhunt","html_url":"https://github.com/st3v3nhunt","followers_url":"https://api.github.com/users/st3v3nhunt/followers","following_url":"https://api.github.com/users/st3v3nhunt/following{/other_user}","gists_url":"https://api.github.com/users/st3v3nhunt/gists{/gist_id}","starred_url":"https://api.github.com/users/st3v3nhunt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/st3v3nhunt/subscriptions","organizations_url":"https://api.github.com/users/st3v3nhunt/orgs","repos_url":"https://api.github.com/users/st3v3nhunt/repos","events_url":"https://api.github.com/users/st3v3nhunt/events{/privacy}","received_events_url":"https://api.github.com/users/st3v3nhunt/received_events","type":"User","site_admin":false},"body":"In this commit I've moved most of the checking of input into the middleware rather than doing it in both middleware and lib. I've ummed and ahhed about whether I should take out the validation from the lib but I'm not a fan of having it duplicated and don't believe the lib is the right place for it so I have moved it...\r\nThere is still work to be done on this code - i'm thinking specifically to stop passing `geo` from middleware to lib. And I think the tests could be condensed down further.","created_at":"2016-12-08T16:14:59Z","updated_at":"2016-12-12T09:29:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"af324925b298ca8614ff45b54ff7c4120e3e4a92","assignee":{"login":"neilbmclaughlin","id":212582,"avatar_url":"https://avatars.githubusercontent.com/u/212582?v=3","gravatar_id":"","url":"https://api.github.com/users/neilbmclaughlin","html_url":"https://github.com/neilbmclaughlin","followers_url":"https://api.github.com/users/neilbmclaughlin/followers","following_url":"https://api.github.com/users/neilbmclaughlin/following{/other_user}","gists_url":"https://api.github.com/users/neilbmclaughlin/gists{/gist_id}","starred_url":"https://api.github.com/users/neilbmclaughlin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/neilbmclaughlin/subscriptions","organizations_url":"https://api.github.com/users/neilbmclaughlin/orgs","repos_url":"https://api.github.com/users/neilbmclaughlin/repos","events_url":"https://api.github.com/users/neilbmclaughlin/events{/privacy}","received_events_url":"https://api.github.com/users/neilbmclaughlin/received_events","type":"User","site_admin":false},"assignees":[{"login":"neilbmclaughlin","id":212582,"avatar_url":"https://avatars.githubusercontent.com/u/212582?v=3","gravatar_id":"","url":"https://api.github.com/users/neilbmclaughlin","html_url":"https://github.com/neilbmclaughlin","followers_url":"https://api.github.com/users/neilbmclaughlin/followers","following_url":"https://api.github.com/users/neilbmclaughlin/following{/other_user}","gists_url":"https://api.github.com/users/neilbmclaughlin/gists{/gist_id}","starred_url":"https://api.github.com/users/neilbmclaughlin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/neilbmclaughlin/subscriptions","organizations_url":"https://api.github.com/users/neilbmclaughlin/orgs","repos_url":"https://api.github.com/users/neilbmclaughlin/repos","events_url":"https://api.github.com/users/neilbmclaughlin/events{/privacy}","received_events_url":"https://api.github.com/users/neilbmclaughlin/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/nhsuk/nearby-services-api/pulls/21/commits","review_comments_url":"https://api.github.com/repos/nhsuk/nearby-services-api/pulls/21/comments","review_comment_url":"https://api.github.com/repos/nhsuk/nearby-services-api/pulls/comments{/number}","comments_url":"https://api.github.com/repos/nhsuk/nearby-services-api/issues/21/comments","statuses_url":"https://api.github.com/repos/nhsuk/nearby-services-api/statuses/6b177774d3663c82ef51785af3a8e411b43877de","head":{"label":"nhsuk:feature/vary-results-returned","ref":"feature/vary-results-returned","sha":"6b177774d3663c82ef51785af3a8e411b43877de","user":{"login":"nhsuk","id":18658529,"avatar_url":"https://avatars.githubusercontent.com/u/18658529?v=3","gravatar_id":"","url":"https://api.github.com/users/nhsuk","html_url":"https://github.com/nhsuk","followers_url":"https://api.github.com/users/nhsuk/followers","following_url":"https://api.github.com/users/nhsuk/following{/other_user}","gists_url":"https://api.github.com/users/nhsuk/gists{/gist_id}","starred_url":"https://api.github.com/users/nhsuk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nhsuk/subscriptions","organizations_url":"https://api.github.com/users/nhsuk/orgs","repos_url":"https://api.github.com/users/nhsuk/repos","events_url":"https://api.github.com/users/nhsuk/events{/privacy}","received_events_url":"https://api.github.com/users/nhsuk/received_events","type":"Organization","site_admin":false},"repo":{"id":73835517,"name":"nearby-services-api","full_name":"nhsuk/nearby-services-api","owner":{"login":"nhsuk","id":18658529,"avatar_url":"https://avatars.githubusercontent.com/u/18658529?v=3","gravatar_id":"","url":"https://api.github.com/users/nhsuk","html_url":"https://github.com/nhsuk","followers_url":"https://api.github.com/users/nhsuk/followers","following_url":"https://api.github.com/users/nhsuk/following{/other_user}","gists_url":"https://api.github.com/users/nhsuk/gists{/gist_id}","starred_url":"https://api.github.com/users/nhsuk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nhsuk/subscriptions","organizations_url":"https://api.github.com/users/nhsuk/orgs","repos_url":"https://api.github.com/users/nhsuk/repos","events_url":"https://api.github.com/users/nhsuk/events{/privacy}","received_events_url":"https://api.github.com/users/nhsuk/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/nhsuk/nearby-services-api","description":null,"fork":false,"url":"https://api.github.com/repos/nhsuk/nearby-services-api","forks_url":"https://api.github.com/repos/nhsuk/nearby-services-api/forks","keys_url":"https://api.github.com/repos/nhsuk/nearby-services-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nhsuk/nearby-services-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nhsuk/nearby-services-api/teams","hooks_url":"https://api.github.com/repos/nhsuk/nearby-services-api/hooks","issue_events_url":"https://api.github.com/repos/nhsuk/nearby-services-api/issues/events{/number}","events_url":"https://api.github.com/repos/nhsuk/nearby-services-api/events","assignees_url":"https://api.github.com/repos/nhsuk/nearby-services-api/assignees{/user}","branches_url":"https://api.github.com/repos/nhsuk/nearby-services-api/branches{/branch}","tags_url":"https://api.github.com/repos/nhsuk/nearby-services-api/tags","blobs_url":"https://api.github.com/repos/nhsuk/nearby-services-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nhsuk/nearby-services-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nhsuk/nearby-services-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/nhsuk/nearby-services-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nhsuk/nearby-services-api/statuses/{sha}","languages_url":"https://api.github.com/repos/nhsuk/nearby-services-api/languages","stargazers_url":"https://api.github.com/repos/nhsuk/nearby-services-api/stargazers","contributors_url":"https://api.github.com/repos/nhsuk/nearby-services-api/contributors","subscribers_url":"https://api.github.com/repos/nhsuk/nearby-services-api/subscribers","subscription_url":"https://api.github.com/repos/nhsuk/nearby-services-api/subscription","commits_url":"https://api.github.com/repos/nhsuk/nearby-services-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/nhsuk/nearby-services-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/nhsuk/nearby-services-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/nhsuk/nearby-services-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/nhsuk/nearby-services-api/contents/{+path}","compare_url":"https://api.github.com/repos/nhsuk/nearby-services-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nhsuk/nearby-services-api/merges","archive_url":"https://api.github.com/repos/nhsuk/nearby-services-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nhsuk/nearby-services-api/downloads","issues_url":"https://api.github.com/repos/nhsuk/nearby-services-api/issues{/number}","pulls_url":"https://api.github.com/repos/nhsuk/nearby-services-api/pulls{/number}","milestones_url":"https://api.github.com/repos/nhsuk/nearby-services-api/milestones{/number}","notifications_url":"https://api.github.com/repos/nhsuk/nearby-services-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nhsuk/nearby-services-api/labels{/name}","releases_url":"https://api.github.com/repos/nhsuk/nearby-services-api/releases{/id}","deployments_url":"https://api.github.com/repos/nhsuk/nearby-services-api/deployments","created_at":"2016-11-15T16:56:29Z","updated_at":"2016-11-15T16:56:54Z","pushed_at":"2016-12-09T07:50:35Z","git_url":"git://github.com/nhsuk/nearby-services-api.git","ssh_url":"git@github.com:nhsuk/nearby-services-api.git","clone_url":"https://github.com/nhsuk/nearby-services-api.git","svn_url":"https://github.com/nhsuk/nearby-services-api","homepage":null,"size":3539,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":5,"forks":0,"open_issues":5,"watchers":0,"default_branch":"master"}},"base":{"label":"nhsuk:master","ref":"master","sha":"747ecbba33d8aa4ae34b68563f250d55d4be121e","user":{"login":"nhsuk","id":18658529,"avatar_url":"https://avatars.githubusercontent.com/u/18658529?v=3","gravatar_id":"","url":"https://api.github.com/users/nhsuk","html_url":"https://github.com/nhsuk","followers_url":"https://api.github.com/users/nhsuk/followers","following_url":"https://api.github.com/users/nhsuk/following{/other_user}","gists_url":"https://api.github.com/users/nhsuk/gists{/gist_id}","starred_url":"https://api.github.com/users/nhsuk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nhsuk/subscriptions","organizations_url":"https://api.github.com/users/nhsuk/orgs","repos_url":"https://api.github.com/users/nhsuk/repos","events_url":"https://api.github.com/users/nhsuk/events{/privacy}","received_events_url":"https://api.github.com/users/nhsuk/received_events","type":"Organization","site_admin":false},"repo":{"id":73835517,"name":"nearby-services-api","full_name":"nhsuk/nearby-services-api","owner":{"login":"nhsuk","id":18658529,"avatar_url":"https://avatars.githubusercontent.com/u/18658529?v=3","gravatar_id":"","url":"https://api.github.com/users/nhsuk","html_url":"https://github.com/nhsuk","followers_url":"https://api.github.com/users/nhsuk/followers","following_url":"https://api.github.com/users/nhsuk/following{/other_user}","gists_url":"https://api.github.com/users/nhsuk/gists{/gist_id}","starred_url":"https://api.github.com/users/nhsuk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nhsuk/subscriptions","organizations_url":"https://api.github.com/users/nhsuk/orgs","repos_url":"https://api.github.com/users/nhsuk/repos","events_url":"https://api.github.com/users/nhsuk/events{/privacy}","received_events_url":"https://api.github.com/users/nhsuk/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/nhsuk/nearby-services-api","description":null,"fork":false,"url":"https://api.github.com/repos/nhsuk/nearby-services-api","forks_url":"https://api.github.com/repos/nhsuk/nearby-services-api/forks","keys_url":"https://api.github.com/repos/nhsuk/nearby-services-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nhsuk/nearby-services-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nhsuk/nearby-services-api/teams","hooks_url":"https://api.github.com/repos/nhsuk/nearby-services-api/hooks","issue_events_url":"https://api.github.com/repos/nhsuk/nearby-services-api/issues/events{/number}","events_url":"https://api.github.com/repos/nhsuk/nearby-services-api/events","assignees_url":"https://api.github.com/repos/nhsuk/nearby-services-api/assignees{/user}","branches_url":"https://api.github.com/repos/nhsuk/nearby-services-api/branches{/branch}","tags_url":"https://api.github.com/repos/nhsuk/nearby-services-api/tags","blobs_url":"https://api.github.com/repos/nhsuk/nearby-services-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nhsuk/nearby-services-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nhsuk/nearby-services-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/nhsuk/nearby-services-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nhsuk/nearby-services-api/statuses/{sha}","languages_url":"https://api.github.com/repos/nhsuk/nearby-services-api/languages","stargazers_url":"https://api.github.com/repos/nhsuk/nearby-services-api/stargazers","contributors_url":"https://api.github.com/repos/nhsuk/nearby-services-api/contributors","subscribers_url":"https://api.github.com/repos/nhsuk/nearby-services-api/subscribers","subscription_url":"https://api.github.com/repos/nhsuk/nearby-services-api/subscription","commits_url":"https://api.github.com/repos/nhsuk/nearby-services-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/nhsuk/nearby-services-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/nhsuk/nearby-services-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/nhsuk/nearby-services-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/nhsuk/nearby-services-api/contents/{+path}","compare_url":"https://api.github.com/repos/nhsuk/nearby-services-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nhsuk/nearby-services-api/merges","archive_url":"https://api.github.com/repos/nhsuk/nearby-services-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nhsuk/nearby-services-api/downloads","issues_url":"https://api.github.com/repos/nhsuk/nearby-services-api/issues{/number}","pulls_url":"https://api.github.com/repos/nhsuk/nearby-services-api/pulls{/number}","milestones_url":"https://api.github.com/repos/nhsuk/nearby-services-api/milestones{/number}","notifications_url":"https://api.github.com/repos/nhsuk/nearby-services-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nhsuk/nearby-services-api/labels{/name}","releases_url":"https://api.github.com/repos/nhsuk/nearby-services-api/releases{/id}","deployments_url":"https://api.github.com/repos/nhsuk/nearby-services-api/deployments","created_at":"2016-11-15T16:56:29Z","updated_at":"2016-11-15T16:56:54Z","pushed_at":"2016-12-09T07:50:35Z","git_url":"git://github.com/nhsuk/nearby-services-api.git","ssh_url":"git@github.com:nhsuk/nearby-services-api.git","clone_url":"https://github.com/nhsuk/nearby-services-api.git","svn_url":"https://github.com/nhsuk/nearby-services-api","homepage":null,"size":3539,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":5,"forks":0,"open_issues":5,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/nhsuk/nearby-services-api/pulls/21"},"html":{"href":"https://github.com/nhsuk/nearby-services-api/pull/21"},"issue":{"href":"https://api.github.com/repos/nhsuk/nearby-services-api/issues/21"},"comments":{"href":"https://api.github.com/repos/nhsuk/nearby-services-api/issues/21/comments"},"review_comments":{"href":"https://api.github.com/repos/nhsuk/nearby-services-api/pulls/21/comments"},"review_comment":{"href":"https://api.github.com/repos/nhsuk/nearby-services-api/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/nhsuk/nearby-services-api/pulls/21/commits"},"statuses":{"href":"https://api.github.com/repos/nhsuk/nearby-services-api/statuses/6b177774d3663c82ef51785af3a8e411b43877de"}}}}
{"actor":{"display_login":"neilbmclaughlin"}}