{"action":"created","comment":{"url":"https://api.github.com/repos/odota/ui/pulls/comments/103113628","pull_request_review_id":23890801,"id":103113628,"diff_hunk":"@@ -33,33 +36,60 @@ export const getPlayerTrendsError = (payload, id) => ({\n   id,\n });\n \n+const getCumalativeSums = (matches, fieldName) =>\n+  matches.reduce((cumulativeList, match, index) => {\n+    if (cumulativeList.length > 0) {\n+      const prevTotal = cumulativeList[index - 1];\n+      cumulativeList.push(prevTotal + match[fieldName]);\n+    } else {\n+      cumulativeList.push(match[fieldName]);\n+    }\n+    return cumulativeList;\n+  }, []);\n+\n+const getWinRateCumlativeSums = matches =>\n+  matches.reduce((cumulativeList, match, index) => {\n+    // 1 for win 0 for loss\n+    const winInt = match.radiant_win === isRadiant(match.player_slot) ? 1 : 0;\n+    if (index === 0) {\n+      cumulativeList.push(winInt);\n+    } else {\n+      const prevRate = cumulativeList[index - 1];\n+      const newRate = ((prevRate * index) + winInt) / (index + 1);\n+      cumulativeList.push(newRate);\n+    }\n+\n+    return cumulativeList;\n+  }, []);\n+\n export const getPlayerTrends = (playerId, options = {}, fieldName) => (dispatch) => {\n   dispatch(getPlayerTrendsRequest(playerId));\n   return fetch(`${API_HOST}${getUrl(playerId, options, url)}`)\n     .then(response => response.json())\n     .then((response) => {","path":"src/actions/player/playerTrendsActions.js","position":44,"original_position":44,"commit_id":"343d5eee36f90d2d6150fa538c4222fc881efb06","original_commit_id":"343d5eee36f90d2d6150fa538c4222fc881efb06","user":{"login":"howardchung","id":3134520,"avatar_url":"https://avatars.githubusercontent.com/u/3134520?v=3","gravatar_id":"","url":"https://api.github.com/users/howardchung","html_url":"https://github.com/howardchung","followers_url":"https://api.github.com/users/howardchung/followers","following_url":"https://api.github.com/users/howardchung/following{/other_user}","gists_url":"https://api.github.com/users/howardchung/gists{/gist_id}","starred_url":"https://api.github.com/users/howardchung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/howardchung/subscriptions","organizations_url":"https://api.github.com/users/howardchung/orgs","repos_url":"https://api.github.com/users/howardchung/repos","events_url":"https://api.github.com/users/howardchung/events{/privacy}","received_events_url":"https://api.github.com/users/howardchung/received_events","type":"User","site_admin":false},"body":"can you just .map() the response to add a field called win_rate with a value of 0 or 1?  Then you can just reuse the existing logic?","created_at":"2017-02-26T19:25:26Z","updated_at":"2017-02-26T19:26:49Z","html_url":"https://github.com/odota/ui/pull/754#discussion_r103113628","pull_request_url":"https://api.github.com/repos/odota/ui/pulls/754","_links":{"self":{"href":"https://api.github.com/repos/odota/ui/pulls/comments/103113628"},"html":{"href":"https://github.com/odota/ui/pull/754#discussion_r103113628"},"pull_request":{"href":"https://api.github.com/repos/odota/ui/pulls/754"}}},"pull_request":{"url":"https://api.github.com/repos/odota/ui/pulls/754","id":108017358,"html_url":"https://github.com/odota/ui/pull/754","diff_url":"https://github.com/odota/ui/pull/754.diff","patch_url":"https://github.com/odota/ui/pull/754.patch","issue_url":"https://api.github.com/repos/odota/ui/issues/754","number":754,"state":"open","locked":false,"title":"Add winrate trend","user":{"login":"masad-frost","id":1994028,"avatar_url":"https://avatars.githubusercontent.com/u/1994028?v=3","gravatar_id":"","url":"https://api.github.com/users/masad-frost","html_url":"https://github.com/masad-frost","followers_url":"https://api.github.com/users/masad-frost/followers","following_url":"https://api.github.com/users/masad-frost/following{/other_user}","gists_url":"https://api.github.com/users/masad-frost/gists{/gist_id}","starred_url":"https://api.github.com/users/masad-frost/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/masad-frost/subscriptions","organizations_url":"https://api.github.com/users/masad-frost/orgs","repos_url":"https://api.github.com/users/masad-frost/repos","events_url":"https://api.github.com/users/masad-frost/events{/privacy}","received_events_url":"https://api.github.com/users/masad-frost/received_events","type":"User","site_admin":false},"body":"fixes #427 ","created_at":"2017-02-26T19:14:39Z","updated_at":"2017-02-26T19:26:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"acea0df868151f8ce9f734c7d0a5961c457bd86b","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/odota/ui/pulls/754/commits","review_comments_url":"https://api.github.com/repos/odota/ui/pulls/754/comments","review_comment_url":"https://api.github.com/repos/odota/ui/pulls/comments{/number}","comments_url":"https://api.github.com/repos/odota/ui/issues/754/comments","statuses_url":"https://api.github.com/repos/odota/ui/statuses/343d5eee36f90d2d6150fa538c4222fc881efb06","head":{"label":"masad-frost:fm-trend-winrate","ref":"fm-trend-winrate","sha":"343d5eee36f90d2d6150fa538c4222fc881efb06","user":{"login":"masad-frost","id":1994028,"avatar_url":"https://avatars.githubusercontent.com/u/1994028?v=3","gravatar_id":"","url":"https://api.github.com/users/masad-frost","html_url":"https://github.com/masad-frost","followers_url":"https://api.github.com/users/masad-frost/followers","following_url":"https://api.github.com/users/masad-frost/following{/other_user}","gists_url":"https://api.github.com/users/masad-frost/gists{/gist_id}","starred_url":"https://api.github.com/users/masad-frost/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/masad-frost/subscriptions","organizations_url":"https://api.github.com/users/masad-frost/orgs","repos_url":"https://api.github.com/users/masad-frost/repos","events_url":"https://api.github.com/users/masad-frost/events{/privacy}","received_events_url":"https://api.github.com/users/masad-frost/received_events","type":"User","site_admin":false},"repo":{"id":79566681,"name":"ui","full_name":"masad-frost/ui","owner":{"login":"masad-frost","id":1994028,"avatar_url":"https://avatars.githubusercontent.com/u/1994028?v=3","gravatar_id":"","url":"https://api.github.com/users/masad-frost","html_url":"https://github.com/masad-frost","followers_url":"https://api.github.com/users/masad-frost/followers","following_url":"https://api.github.com/users/masad-frost/following{/other_user}","gists_url":"https://api.github.com/users/masad-frost/gists{/gist_id}","starred_url":"https://api.github.com/users/masad-frost/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/masad-frost/subscriptions","organizations_url":"https://api.github.com/users/masad-frost/orgs","repos_url":"https://api.github.com/users/masad-frost/repos","events_url":"https://api.github.com/users/masad-frost/events{/privacy}","received_events_url":"https://api.github.com/users/masad-frost/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/masad-frost/ui","description":"OpenDota UI: A web interface for viewing Dota 2 data","fork":true,"url":"https://api.github.com/repos/masad-frost/ui","forks_url":"https://api.github.com/repos/masad-frost/ui/forks","keys_url":"https://api.github.com/repos/masad-frost/ui/keys{/key_id}","collaborators_url":"https://api.github.com/repos/masad-frost/ui/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/masad-frost/ui/teams","hooks_url":"https://api.github.com/repos/masad-frost/ui/hooks","issue_events_url":"https://api.github.com/repos/masad-frost/ui/issues/events{/number}","events_url":"https://api.github.com/repos/masad-frost/ui/events","assignees_url":"https://api.github.com/repos/masad-frost/ui/assignees{/user}","branches_url":"https://api.github.com/repos/masad-frost/ui/branches{/branch}","tags_url":"https://api.github.com/repos/masad-frost/ui/tags","blobs_url":"https://api.github.com/repos/masad-frost/ui/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/masad-frost/ui/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/masad-frost/ui/git/refs{/sha}","trees_url":"https://api.github.com/repos/masad-frost/ui/git/trees{/sha}","statuses_url":"https://api.github.com/repos/masad-frost/ui/statuses/{sha}","languages_url":"https://api.github.com/repos/masad-frost/ui/languages","stargazers_url":"https://api.github.com/repos/masad-frost/ui/stargazers","contributors_url":"https://api.github.com/repos/masad-frost/ui/contributors","subscribers_url":"https://api.github.com/repos/masad-frost/ui/subscribers","subscription_url":"https://api.github.com/repos/masad-frost/ui/subscription","commits_url":"https://api.github.com/repos/masad-frost/ui/commits{/sha}","git_commits_url":"https://api.github.com/repos/masad-frost/ui/git/commits{/sha}","comments_url":"https://api.github.com/repos/masad-frost/ui/comments{/number}","issue_comment_url":"https://api.github.com/repos/masad-frost/ui/issues/comments{/number}","contents_url":"https://api.github.com/repos/masad-frost/ui/contents/{+path}","compare_url":"https://api.github.com/repos/masad-frost/ui/compare/{base}...{head}","merges_url":"https://api.github.com/repos/masad-frost/ui/merges","archive_url":"https://api.github.com/repos/masad-frost/ui/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/masad-frost/ui/downloads","issues_url":"https://api.github.com/repos/masad-frost/ui/issues{/number}","pulls_url":"https://api.github.com/repos/masad-frost/ui/pulls{/number}","milestones_url":"https://api.github.com/repos/masad-frost/ui/milestones{/number}","notifications_url":"https://api.github.com/repos/masad-frost/ui/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/masad-frost/ui/labels{/name}","releases_url":"https://api.github.com/repos/masad-frost/ui/releases{/id}","deployments_url":"https://api.github.com/repos/masad-frost/ui/deployments","created_at":"2017-01-20T14:39:57Z","updated_at":"2017-01-20T14:40:00Z","pushed_at":"2017-02-26T19:10:56Z","git_url":"git://github.com/masad-frost/ui.git","ssh_url":"git@github.com:masad-frost/ui.git","clone_url":"https://github.com/masad-frost/ui.git","svn_url":"https://github.com/masad-frost/ui","homepage":"https://www.opendota.com","size":18469,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"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":"odota:master","ref":"master","sha":"4fd50f7d98b28b25f39d7f5dafa746a20fb1ecf1","user":{"login":"odota","id":10602524,"avatar_url":"https://avatars.githubusercontent.com/u/10602524?v=3","gravatar_id":"","url":"https://api.github.com/users/odota","html_url":"https://github.com/odota","followers_url":"https://api.github.com/users/odota/followers","following_url":"https://api.github.com/users/odota/following{/other_user}","gists_url":"https://api.github.com/users/odota/gists{/gist_id}","starred_url":"https://api.github.com/users/odota/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/odota/subscriptions","organizations_url":"https://api.github.com/users/odota/orgs","repos_url":"https://api.github.com/users/odota/repos","events_url":"https://api.github.com/users/odota/events{/privacy}","received_events_url":"https://api.github.com/users/odota/received_events","type":"Organization","site_admin":false},"repo":{"id":59816990,"name":"ui","full_name":"odota/ui","owner":{"login":"odota","id":10602524,"avatar_url":"https://avatars.githubusercontent.com/u/10602524?v=3","gravatar_id":"","url":"https://api.github.com/users/odota","html_url":"https://github.com/odota","followers_url":"https://api.github.com/users/odota/followers","following_url":"https://api.github.com/users/odota/following{/other_user}","gists_url":"https://api.github.com/users/odota/gists{/gist_id}","starred_url":"https://api.github.com/users/odota/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/odota/subscriptions","organizations_url":"https://api.github.com/users/odota/orgs","repos_url":"https://api.github.com/users/odota/repos","events_url":"https://api.github.com/users/odota/events{/privacy}","received_events_url":"https://api.github.com/users/odota/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/odota/ui","description":"OpenDota UI: A web interface for viewing Dota 2 data","fork":false,"url":"https://api.github.com/repos/odota/ui","forks_url":"https://api.github.com/repos/odota/ui/forks","keys_url":"https://api.github.com/repos/odota/ui/keys{/key_id}","collaborators_url":"https://api.github.com/repos/odota/ui/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/odota/ui/teams","hooks_url":"https://api.github.com/repos/odota/ui/hooks","issue_events_url":"https://api.github.com/repos/odota/ui/issues/events{/number}","events_url":"https://api.github.com/repos/odota/ui/events","assignees_url":"https://api.github.com/repos/odota/ui/assignees{/user}","branches_url":"https://api.github.com/repos/odota/ui/branches{/branch}","tags_url":"https://api.github.com/repos/odota/ui/tags","blobs_url":"https://api.github.com/repos/odota/ui/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/odota/ui/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/odota/ui/git/refs{/sha}","trees_url":"https://api.github.com/repos/odota/ui/git/trees{/sha}","statuses_url":"https://api.github.com/repos/odota/ui/statuses/{sha}","languages_url":"https://api.github.com/repos/odota/ui/languages","stargazers_url":"https://api.github.com/repos/odota/ui/stargazers","contributors_url":"https://api.github.com/repos/odota/ui/contributors","subscribers_url":"https://api.github.com/repos/odota/ui/subscribers","subscription_url":"https://api.github.com/repos/odota/ui/subscription","commits_url":"https://api.github.com/repos/odota/ui/commits{/sha}","git_commits_url":"https://api.github.com/repos/odota/ui/git/commits{/sha}","comments_url":"https://api.github.com/repos/odota/ui/comments{/number}","issue_comment_url":"https://api.github.com/repos/odota/ui/issues/comments{/number}","contents_url":"https://api.github.com/repos/odota/ui/contents/{+path}","compare_url":"https://api.github.com/repos/odota/ui/compare/{base}...{head}","merges_url":"https://api.github.com/repos/odota/ui/merges","archive_url":"https://api.github.com/repos/odota/ui/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/odota/ui/downloads","issues_url":"https://api.github.com/repos/odota/ui/issues{/number}","pulls_url":"https://api.github.com/repos/odota/ui/pulls{/number}","milestones_url":"https://api.github.com/repos/odota/ui/milestones{/number}","notifications_url":"https://api.github.com/repos/odota/ui/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/odota/ui/labels{/name}","releases_url":"https://api.github.com/repos/odota/ui/releases{/id}","deployments_url":"https://api.github.com/repos/odota/ui/deployments","created_at":"2016-05-27T08:06:05Z","updated_at":"2017-02-26T01:01:22Z","pushed_at":"2017-02-26T19:14:39Z","git_url":"git://github.com/odota/ui.git","ssh_url":"git@github.com:odota/ui.git","clone_url":"https://github.com/odota/ui.git","svn_url":"https://github.com/odota/ui","homepage":"https://www.opendota.com","size":18482,"stargazers_count":90,"watchers_count":90,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":58,"mirror_url":null,"open_issues_count":47,"forks":58,"open_issues":47,"watchers":90,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/odota/ui/pulls/754"},"html":{"href":"https://github.com/odota/ui/pull/754"},"issue":{"href":"https://api.github.com/repos/odota/ui/issues/754"},"comments":{"href":"https://api.github.com/repos/odota/ui/issues/754/comments"},"review_comments":{"href":"https://api.github.com/repos/odota/ui/pulls/754/comments"},"review_comment":{"href":"https://api.github.com/repos/odota/ui/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/odota/ui/pulls/754/commits"},"statuses":{"href":"https://api.github.com/repos/odota/ui/statuses/343d5eee36f90d2d6150fa538c4222fc881efb06"}}}}
{"actor":{"display_login":"howardchung"}}