{"action":"created","comment":{"url":"https://api.github.com/repos/TwinePlatform/DataPower/pulls/comments/173281193","pull_request_review_id":102446743,"id":173281193,"diff_hunk":"@@ -0,0 +1,241 @@\n+/*\n+ *\n+ */\n+import axios from 'axios';\n+import { zipWith } from 'ramda';\n+\n+const parseAgeFilter = (ageBrackets) => {\n+  const agesLower = (ageBrackets[0] !== 0 ? [0] : []).concat(ageBrackets);\n+  const agesUpper = agesLower\n+    .map(x => x - 1)\n+    .filter(x => x > 0)\n+    .concat(Infinity);","path":"react-backend/client/api_client.js","position":12,"original_position":12,"commit_id":"acb2acecd0c2b881748e563854b94158e1ef4d1f","original_commit_id":"acb2acecd0c2b881748e563854b94158e1ef4d1f","user":{"login":"eliascodes","id":12719553,"avatar_url":"https://avatars3.githubusercontent.com/u/12719553?v=4","gravatar_id":"","url":"https://api.github.com/users/eliascodes","html_url":"https://github.com/eliascodes","followers_url":"https://api.github.com/users/eliascodes/followers","following_url":"https://api.github.com/users/eliascodes/following{/other_user}","gists_url":"https://api.github.com/users/eliascodes/gists{/gist_id}","starred_url":"https://api.github.com/users/eliascodes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eliascodes/subscriptions","organizations_url":"https://api.github.com/users/eliascodes/orgs","repos_url":"https://api.github.com/users/eliascodes/repos","events_url":"https://api.github.com/users/eliascodes/events{/privacy}","received_events_url":"https://api.github.com/users/eliascodes/received_events","type":"User","site_admin":false},"body":"Disagree that this is more readable. Leaving aside the use of a string value that reads like a boolean, `\"false\"` is not an age, and so is out of place in `agesUpper`.\r\n\r\nI may have agreed had you suggested something like:\r\n```js\r\nconst agesUpper = agesLower\r\n  .map(x => x - 1)\r\n  .filter(x => x > 0)\r\n  .concat('more');\r\n\r\nreturn zipWith((x, y) => `${x}-${y}`, agesLower, agesUpper)\r\n```\r\n\r\nBecause it allows us to remove the branch from the final line. Although note that this is mixing presentational concerns with data transformations; the `'more'` is how we represent an undefined upper bound using text.\r\n\r\nMaybe you would prefer:\r\n```js\r\nconst ageToStr = n => Number.isFinite(n) ? `${n}` : 'more'\r\n\r\nconst agesLower = (ageBrackets[0] !== 0 ? [0] : [])\r\n  .concat(ageBrackets)\r\n  .map(ageToStr);\r\n\r\nconst agesUpper = agesLower\r\n  .map(x => x - 1)\r\n  .filter(x => x > 0)\r\n  .concat(Infinity)\r\n  .map(ageToStr);\r\n\r\nreturn zipWith((x, y) => (`${x}-${y}`), agesLower, agesUpper)[0];\r\n```","created_at":"2018-03-08T20:28:39Z","updated_at":"2018-03-08T20:28:39Z","html_url":"https://github.com/TwinePlatform/DataPower/pull/265#discussion_r173281193","pull_request_url":"https://api.github.com/repos/TwinePlatform/DataPower/pulls/265","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/TwinePlatform/DataPower/pulls/comments/173281193"},"html":{"href":"https://github.com/TwinePlatform/DataPower/pull/265#discussion_r173281193"},"pull_request":{"href":"https://api.github.com/repos/TwinePlatform/DataPower/pulls/265"}},"in_reply_to_id":173263782},"pull_request":{"url":"https://api.github.com/repos/TwinePlatform/DataPower/pulls/265","id":173775854,"html_url":"https://github.com/TwinePlatform/DataPower/pull/265","diff_url":"https://github.com/TwinePlatform/DataPower/pull/265.diff","patch_url":"https://github.com/TwinePlatform/DataPower/pull/265.patch","issue_url":"https://api.github.com/repos/TwinePlatform/DataPower/issues/265","number":265,"state":"open","locked":false,"title":"[WIP] Api client","user":{"login":"eliascodes","id":12719553,"avatar_url":"https://avatars3.githubusercontent.com/u/12719553?v=4","gravatar_id":"","url":"https://api.github.com/users/eliascodes","html_url":"https://github.com/eliascodes","followers_url":"https://api.github.com/users/eliascodes/followers","following_url":"https://api.github.com/users/eliascodes/following{/other_user}","gists_url":"https://api.github.com/users/eliascodes/gists{/gist_id}","starred_url":"https://api.github.com/users/eliascodes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eliascodes/subscriptions","organizations_url":"https://api.github.com/users/eliascodes/orgs","repos_url":"https://api.github.com/users/eliascodes/repos","events_url":"https://api.github.com/users/eliascodes/events{/privacy}","received_events_url":"https://api.github.com/users/eliascodes/received_events","type":"User","site_admin":false},"body":"**DON'T MERGE**\r\n\r\nRelated to #264 \r\n\r\nSo this is where I'm at so far, the API client itself is basically done, with the following tasks remaining:\r\n* Add tests\r\n* Substitute calls to `fetch(URL)` with calls to the client\r\n* Remove existing HTTP API helpers\r\n* _(Extra credit)_ add response processing into the client to align the data the react app receives more closely with the [new API design](https://github.com/TwinePlatform/DataPower/blob/master/docs/api_migration_plan.md)\r\n\r\nThe way I've written the client, I've tried to make the API it exposes to the React app consistent, as far as is reasonable, with the new API design, converting inputs to be compatible with the existing API internally. This is why the `Visitors.get` method is relatively complex. All that logic can be deleted once `GET /visitors` works as specified in the new design.","created_at":"2018-03-08T16:01:30Z","updated_at":"2018-03-08T20:28:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bd81925012054dd3d8101471228c0d43c6107749","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":705584914,"url":"https://api.github.com/repos/TwinePlatform/DataPower/labels/in-progress","name":"in-progress","color":"009688","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/TwinePlatform/DataPower/pulls/265/commits","review_comments_url":"https://api.github.com/repos/TwinePlatform/DataPower/pulls/265/comments","review_comment_url":"https://api.github.com/repos/TwinePlatform/DataPower/pulls/comments{/number}","comments_url":"https://api.github.com/repos/TwinePlatform/DataPower/issues/265/comments","statuses_url":"https://api.github.com/repos/TwinePlatform/DataPower/statuses/acb2acecd0c2b881748e563854b94158e1ef4d1f","head":{"label":"TwinePlatform:api-client","ref":"api-client","sha":"acb2acecd0c2b881748e563854b94158e1ef4d1f","user":{"login":"TwinePlatform","id":35457494,"avatar_url":"https://avatars1.githubusercontent.com/u/35457494?v=4","gravatar_id":"","url":"https://api.github.com/users/TwinePlatform","html_url":"https://github.com/TwinePlatform","followers_url":"https://api.github.com/users/TwinePlatform/followers","following_url":"https://api.github.com/users/TwinePlatform/following{/other_user}","gists_url":"https://api.github.com/users/TwinePlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/TwinePlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TwinePlatform/subscriptions","organizations_url":"https://api.github.com/users/TwinePlatform/orgs","repos_url":"https://api.github.com/users/TwinePlatform/repos","events_url":"https://api.github.com/users/TwinePlatform/events{/privacy}","received_events_url":"https://api.github.com/users/TwinePlatform/received_events","type":"Organization","site_admin":false},"repo":{"id":105159384,"name":"DataPower","full_name":"TwinePlatform/DataPower","owner":{"login":"TwinePlatform","id":35457494,"avatar_url":"https://avatars1.githubusercontent.com/u/35457494?v=4","gravatar_id":"","url":"https://api.github.com/users/TwinePlatform","html_url":"https://github.com/TwinePlatform","followers_url":"https://api.github.com/users/TwinePlatform/followers","following_url":"https://api.github.com/users/TwinePlatform/following{/other_user}","gists_url":"https://api.github.com/users/TwinePlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/TwinePlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TwinePlatform/subscriptions","organizations_url":"https://api.github.com/users/TwinePlatform/orgs","repos_url":"https://api.github.com/users/TwinePlatform/repos","events_url":"https://api.github.com/users/TwinePlatform/events{/privacy}","received_events_url":"https://api.github.com/users/TwinePlatform/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/TwinePlatform/DataPower","description":"DataPower - customer data for community businesses","fork":false,"url":"https://api.github.com/repos/TwinePlatform/DataPower","forks_url":"https://api.github.com/repos/TwinePlatform/DataPower/forks","keys_url":"https://api.github.com/repos/TwinePlatform/DataPower/keys{/key_id}","collaborators_url":"https://api.github.com/repos/TwinePlatform/DataPower/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/TwinePlatform/DataPower/teams","hooks_url":"https://api.github.com/repos/TwinePlatform/DataPower/hooks","issue_events_url":"https://api.github.com/repos/TwinePlatform/DataPower/issues/events{/number}","events_url":"https://api.github.com/repos/TwinePlatform/DataPower/events","assignees_url":"https://api.github.com/repos/TwinePlatform/DataPower/assignees{/user}","branches_url":"https://api.github.com/repos/TwinePlatform/DataPower/branches{/branch}","tags_url":"https://api.github.com/repos/TwinePlatform/DataPower/tags","blobs_url":"https://api.github.com/repos/TwinePlatform/DataPower/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/TwinePlatform/DataPower/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/TwinePlatform/DataPower/git/refs{/sha}","trees_url":"https://api.github.com/repos/TwinePlatform/DataPower/git/trees{/sha}","statuses_url":"https://api.github.com/repos/TwinePlatform/DataPower/statuses/{sha}","languages_url":"https://api.github.com/repos/TwinePlatform/DataPower/languages","stargazers_url":"https://api.github.com/repos/TwinePlatform/DataPower/stargazers","contributors_url":"https://api.github.com/repos/TwinePlatform/DataPower/contributors","subscribers_url":"https://api.github.com/repos/TwinePlatform/DataPower/subscribers","subscription_url":"https://api.github.com/repos/TwinePlatform/DataPower/subscription","commits_url":"https://api.github.com/repos/TwinePlatform/DataPower/commits{/sha}","git_commits_url":"https://api.github.com/repos/TwinePlatform/DataPower/git/commits{/sha}","comments_url":"https://api.github.com/repos/TwinePlatform/DataPower/comments{/number}","issue_comment_url":"https://api.github.com/repos/TwinePlatform/DataPower/issues/comments{/number}","contents_url":"https://api.github.com/repos/TwinePlatform/DataPower/contents/{+path}","compare_url":"https://api.github.com/repos/TwinePlatform/DataPower/compare/{base}...{head}","merges_url":"https://api.github.com/repos/TwinePlatform/DataPower/merges","archive_url":"https://api.github.com/repos/TwinePlatform/DataPower/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/TwinePlatform/DataPower/downloads","issues_url":"https://api.github.com/repos/TwinePlatform/DataPower/issues{/number}","pulls_url":"https://api.github.com/repos/TwinePlatform/DataPower/pulls{/number}","milestones_url":"https://api.github.com/repos/TwinePlatform/DataPower/milestones{/number}","notifications_url":"https://api.github.com/repos/TwinePlatform/DataPower/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/TwinePlatform/DataPower/labels{/name}","releases_url":"https://api.github.com/repos/TwinePlatform/DataPower/releases{/id}","deployments_url":"https://api.github.com/repos/TwinePlatform/DataPower/deployments","created_at":"2017-09-28T14:34:45Z","updated_at":"2018-03-01T15:34:42Z","pushed_at":"2018-03-08T17:57:54Z","git_url":"git://github.com/TwinePlatform/DataPower.git","ssh_url":"git@github.com:TwinePlatform/DataPower.git","clone_url":"https://github.com/TwinePlatform/DataPower.git","svn_url":"https://github.com/TwinePlatform/DataPower","homepage":"https://datapower.herokuapp.com/","size":12843,"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":0,"mirror_url":null,"archived":false,"open_issues_count":49,"license":null,"forks":0,"open_issues":49,"watchers":7,"default_branch":"master"}},"base":{"label":"TwinePlatform:master","ref":"master","sha":"1a42f357ce427dade607cfc2eec8bfa5abef98ee","user":{"login":"TwinePlatform","id":35457494,"avatar_url":"https://avatars1.githubusercontent.com/u/35457494?v=4","gravatar_id":"","url":"https://api.github.com/users/TwinePlatform","html_url":"https://github.com/TwinePlatform","followers_url":"https://api.github.com/users/TwinePlatform/followers","following_url":"https://api.github.com/users/TwinePlatform/following{/other_user}","gists_url":"https://api.github.com/users/TwinePlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/TwinePlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TwinePlatform/subscriptions","organizations_url":"https://api.github.com/users/TwinePlatform/orgs","repos_url":"https://api.github.com/users/TwinePlatform/repos","events_url":"https://api.github.com/users/TwinePlatform/events{/privacy}","received_events_url":"https://api.github.com/users/TwinePlatform/received_events","type":"Organization","site_admin":false},"repo":{"id":105159384,"name":"DataPower","full_name":"TwinePlatform/DataPower","owner":{"login":"TwinePlatform","id":35457494,"avatar_url":"https://avatars1.githubusercontent.com/u/35457494?v=4","gravatar_id":"","url":"https://api.github.com/users/TwinePlatform","html_url":"https://github.com/TwinePlatform","followers_url":"https://api.github.com/users/TwinePlatform/followers","following_url":"https://api.github.com/users/TwinePlatform/following{/other_user}","gists_url":"https://api.github.com/users/TwinePlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/TwinePlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TwinePlatform/subscriptions","organizations_url":"https://api.github.com/users/TwinePlatform/orgs","repos_url":"https://api.github.com/users/TwinePlatform/repos","events_url":"https://api.github.com/users/TwinePlatform/events{/privacy}","received_events_url":"https://api.github.com/users/TwinePlatform/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/TwinePlatform/DataPower","description":"DataPower - customer data for community businesses","fork":false,"url":"https://api.github.com/repos/TwinePlatform/DataPower","forks_url":"https://api.github.com/repos/TwinePlatform/DataPower/forks","keys_url":"https://api.github.com/repos/TwinePlatform/DataPower/keys{/key_id}","collaborators_url":"https://api.github.com/repos/TwinePlatform/DataPower/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/TwinePlatform/DataPower/teams","hooks_url":"https://api.github.com/repos/TwinePlatform/DataPower/hooks","issue_events_url":"https://api.github.com/repos/TwinePlatform/DataPower/issues/events{/number}","events_url":"https://api.github.com/repos/TwinePlatform/DataPower/events","assignees_url":"https://api.github.com/repos/TwinePlatform/DataPower/assignees{/user}","branches_url":"https://api.github.com/repos/TwinePlatform/DataPower/branches{/branch}","tags_url":"https://api.github.com/repos/TwinePlatform/DataPower/tags","blobs_url":"https://api.github.com/repos/TwinePlatform/DataPower/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/TwinePlatform/DataPower/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/TwinePlatform/DataPower/git/refs{/sha}","trees_url":"https://api.github.com/repos/TwinePlatform/DataPower/git/trees{/sha}","statuses_url":"https://api.github.com/repos/TwinePlatform/DataPower/statuses/{sha}","languages_url":"https://api.github.com/repos/TwinePlatform/DataPower/languages","stargazers_url":"https://api.github.com/repos/TwinePlatform/DataPower/stargazers","contributors_url":"https://api.github.com/repos/TwinePlatform/DataPower/contributors","subscribers_url":"https://api.github.com/repos/TwinePlatform/DataPower/subscribers","subscription_url":"https://api.github.com/repos/TwinePlatform/DataPower/subscription","commits_url":"https://api.github.com/repos/TwinePlatform/DataPower/commits{/sha}","git_commits_url":"https://api.github.com/repos/TwinePlatform/DataPower/git/commits{/sha}","comments_url":"https://api.github.com/repos/TwinePlatform/DataPower/comments{/number}","issue_comment_url":"https://api.github.com/repos/TwinePlatform/DataPower/issues/comments{/number}","contents_url":"https://api.github.com/repos/TwinePlatform/DataPower/contents/{+path}","compare_url":"https://api.github.com/repos/TwinePlatform/DataPower/compare/{base}...{head}","merges_url":"https://api.github.com/repos/TwinePlatform/DataPower/merges","archive_url":"https://api.github.com/repos/TwinePlatform/DataPower/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/TwinePlatform/DataPower/downloads","issues_url":"https://api.github.com/repos/TwinePlatform/DataPower/issues{/number}","pulls_url":"https://api.github.com/repos/TwinePlatform/DataPower/pulls{/number}","milestones_url":"https://api.github.com/repos/TwinePlatform/DataPower/milestones{/number}","notifications_url":"https://api.github.com/repos/TwinePlatform/DataPower/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/TwinePlatform/DataPower/labels{/name}","releases_url":"https://api.github.com/repos/TwinePlatform/DataPower/releases{/id}","deployments_url":"https://api.github.com/repos/TwinePlatform/DataPower/deployments","created_at":"2017-09-28T14:34:45Z","updated_at":"2018-03-01T15:34:42Z","pushed_at":"2018-03-08T17:57:54Z","git_url":"git://github.com/TwinePlatform/DataPower.git","ssh_url":"git@github.com:TwinePlatform/DataPower.git","clone_url":"https://github.com/TwinePlatform/DataPower.git","svn_url":"https://github.com/TwinePlatform/DataPower","homepage":"https://datapower.herokuapp.com/","size":12843,"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":0,"mirror_url":null,"archived":false,"open_issues_count":49,"license":null,"forks":0,"open_issues":49,"watchers":7,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/TwinePlatform/DataPower/pulls/265"},"html":{"href":"https://github.com/TwinePlatform/DataPower/pull/265"},"issue":{"href":"https://api.github.com/repos/TwinePlatform/DataPower/issues/265"},"comments":{"href":"https://api.github.com/repos/TwinePlatform/DataPower/issues/265/comments"},"review_comments":{"href":"https://api.github.com/repos/TwinePlatform/DataPower/pulls/265/comments"},"review_comment":{"href":"https://api.github.com/repos/TwinePlatform/DataPower/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/TwinePlatform/DataPower/pulls/265/commits"},"statuses":{"href":"https://api.github.com/repos/TwinePlatform/DataPower/statuses/acb2acecd0c2b881748e563854b94158e1ef4d1f"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"eliascodes"}}