{"action":"created","comment":{"url":"https://api.github.com/repos/jelmnainen/exerking-front/pulls/comments/59689459","id":59689459,"diff_hunk":"@@ -0,0 +1,101 @@\n+import React, { Component, PropTypes } from 'react';\n+import { connect } from 'react-redux';\n+\n+import TeacherVisualization from '../components/TeacherVisualization';\n+import { fetchAllSubmissions } from '../actions/submissionsActions';\n+import { fetchExercises } from '../actions/exercisesActions';\n+import { fetchAllUsers } from '../actions/usersActions';\n+import { fetchBatches } from '../actions/batchesActions';\n+import { fetchCategories } from '../actions/categoriesActions';\n+\n+export class TeacherVisualizationContainer extends Component {\n+\n+  componentWillMount() {\n+    this.props.fetchCourseData();\n+  }\n+\n+  calculateExerciseProgress() {\n+    return {\n+      total: this.props.exercises.count() * this.props.users.count(),\n+      done: this.props.submissions.count(),\n+    };\n+  }\n+\n+  calculateProgress(groupKey, getTitle, sortBy) {\n+    return this.props.exercises\n+      .filter(exercise => exercise.get(groupKey))\n+      .groupBy(exercise => exercise.get(groupKey))\n+      .map(exercises => ({\n+        total: exercises.count() * this.props.users.count(),\n+        done: exercises\n+          .map(exercise =>\n+            this.props.submissions\n+              .filter(submission => submission.get('exercise_id') === exercise.get('id'))\n+          )\n+          .reduce((prev, curr) => prev + curr.count(), 0),\n+      }))\n+      .map((result, id) => Object.assign(result, {\n+        id,\n+        title: getTitle(id),\n+      }))\n+      .sortBy(sortBy)\n+      .toArray();\n+  }\n+\n+  calculateBatchProgress() {\n+    return this.calculateProgress(\n+      'batch_id',\n+      (id) => this.props.batches.getIn([id, 'title']),\n+      ({ id }) => this.props.batches.getIn([id, 'deadline'])\n+    );\n+  }\n+\n+  calculateCategoryProgress() {\n+    return this.calculateProgress(\n+      'category_id',\n+      (id) => this.props.categories.getIn([id, 'title']),\n+      ({ title }) => title\n+    );\n+  }\n+\n+  render() {\n+    return (\n+      <TeacherVisualization","path":"src/containers/TeacherVisualizationContainer.jsx","position":63,"original_position":63,"commit_id":"84fdab106174e0df98266c14121b478703e66144","original_commit_id":"84fdab106174e0df98266c14121b478703e66144","user":{"login":"nfrolov","id":920905,"avatar_url":"https://avatars.githubusercontent.com/u/920905?v=3","gravatar_id":"","url":"https://api.github.com/users/nfrolov","html_url":"https://github.com/nfrolov","followers_url":"https://api.github.com/users/nfrolov/followers","following_url":"https://api.github.com/users/nfrolov/following{/other_user}","gists_url":"https://api.github.com/users/nfrolov/gists{/gist_id}","starred_url":"https://api.github.com/users/nfrolov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nfrolov/subscriptions","organizations_url":"https://api.github.com/users/nfrolov/orgs","repos_url":"https://api.github.com/users/nfrolov/repos","events_url":"https://api.github.com/users/nfrolov/events{/privacy}","received_events_url":"https://api.github.com/users/nfrolov/received_events","type":"User","site_admin":false},"body":"Actually this is \"right\" way. Our current components are not dumb. They known about Redux and are responsible for data fetching. That should be container's responsibility.","created_at":"2016-04-14T09:45:38Z","updated_at":"2016-04-14T09:45:38Z","html_url":"https://github.com/jelmnainen/exerking-front/pull/63#discussion_r59689459","pull_request_url":"https://api.github.com/repos/jelmnainen/exerking-front/pulls/63","_links":{"self":{"href":"https://api.github.com/repos/jelmnainen/exerking-front/pulls/comments/59689459"},"html":{"href":"https://github.com/jelmnainen/exerking-front/pull/63#discussion_r59689459"},"pull_request":{"href":"https://api.github.com/repos/jelmnainen/exerking-front/pulls/63"}}},"pull_request":{"url":"https://api.github.com/repos/jelmnainen/exerking-front/pulls/63","id":66164081,"html_url":"https://github.com/jelmnainen/exerking-front/pull/63","diff_url":"https://github.com/jelmnainen/exerking-front/pull/63.diff","patch_url":"https://github.com/jelmnainen/exerking-front/pull/63.patch","issue_url":"https://api.github.com/repos/jelmnainen/exerking-front/issues/63","number":63,"state":"open","locked":false,"title":"course progress visuals","user":{"login":"tmekkelisti","id":3275584,"avatar_url":"https://avatars.githubusercontent.com/u/3275584?v=3","gravatar_id":"","url":"https://api.github.com/users/tmekkelisti","html_url":"https://github.com/tmekkelisti","followers_url":"https://api.github.com/users/tmekkelisti/followers","following_url":"https://api.github.com/users/tmekkelisti/following{/other_user}","gists_url":"https://api.github.com/users/tmekkelisti/gists{/gist_id}","starred_url":"https://api.github.com/users/tmekkelisti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tmekkelisti/subscriptions","organizations_url":"https://api.github.com/users/tmekkelisti/orgs","repos_url":"https://api.github.com/users/tmekkelisti/repos","events_url":"https://api.github.com/users/tmekkelisti/events{/privacy}","received_events_url":"https://api.github.com/users/tmekkelisti/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-04-12T14:10:24Z","updated_at":"2016-04-14T09:45:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d002089aa85681f8c474a1106d78ec501175808b","assignee":{"login":"jelmnainen","id":5445441,"avatar_url":"https://avatars.githubusercontent.com/u/5445441?v=3","gravatar_id":"","url":"https://api.github.com/users/jelmnainen","html_url":"https://github.com/jelmnainen","followers_url":"https://api.github.com/users/jelmnainen/followers","following_url":"https://api.github.com/users/jelmnainen/following{/other_user}","gists_url":"https://api.github.com/users/jelmnainen/gists{/gist_id}","starred_url":"https://api.github.com/users/jelmnainen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jelmnainen/subscriptions","organizations_url":"https://api.github.com/users/jelmnainen/orgs","repos_url":"https://api.github.com/users/jelmnainen/repos","events_url":"https://api.github.com/users/jelmnainen/events{/privacy}","received_events_url":"https://api.github.com/users/jelmnainen/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/jelmnainen/exerking-front/pulls/63/commits","review_comments_url":"https://api.github.com/repos/jelmnainen/exerking-front/pulls/63/comments","review_comment_url":"https://api.github.com/repos/jelmnainen/exerking-front/pulls/comments{/number}","comments_url":"https://api.github.com/repos/jelmnainen/exerking-front/issues/63/comments","statuses_url":"https://api.github.com/repos/jelmnainen/exerking-front/statuses/84fdab106174e0df98266c14121b478703e66144","head":{"label":"jelmnainen:teacher-visualization","ref":"teacher-visualization","sha":"84fdab106174e0df98266c14121b478703e66144","user":{"login":"jelmnainen","id":5445441,"avatar_url":"https://avatars.githubusercontent.com/u/5445441?v=3","gravatar_id":"","url":"https://api.github.com/users/jelmnainen","html_url":"https://github.com/jelmnainen","followers_url":"https://api.github.com/users/jelmnainen/followers","following_url":"https://api.github.com/users/jelmnainen/following{/other_user}","gists_url":"https://api.github.com/users/jelmnainen/gists{/gist_id}","starred_url":"https://api.github.com/users/jelmnainen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jelmnainen/subscriptions","organizations_url":"https://api.github.com/users/jelmnainen/orgs","repos_url":"https://api.github.com/users/jelmnainen/repos","events_url":"https://api.github.com/users/jelmnainen/events{/privacy}","received_events_url":"https://api.github.com/users/jelmnainen/received_events","type":"User","site_admin":false},"repo":{"id":49961467,"name":"exerking-front","full_name":"jelmnainen/exerking-front","owner":{"login":"jelmnainen","id":5445441,"avatar_url":"https://avatars.githubusercontent.com/u/5445441?v=3","gravatar_id":"","url":"https://api.github.com/users/jelmnainen","html_url":"https://github.com/jelmnainen","followers_url":"https://api.github.com/users/jelmnainen/followers","following_url":"https://api.github.com/users/jelmnainen/following{/other_user}","gists_url":"https://api.github.com/users/jelmnainen/gists{/gist_id}","starred_url":"https://api.github.com/users/jelmnainen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jelmnainen/subscriptions","organizations_url":"https://api.github.com/users/jelmnainen/orgs","repos_url":"https://api.github.com/users/jelmnainen/repos","events_url":"https://api.github.com/users/jelmnainen/events{/privacy}","received_events_url":"https://api.github.com/users/jelmnainen/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jelmnainen/exerking-front","description":"An exercise marking system","fork":false,"url":"https://api.github.com/repos/jelmnainen/exerking-front","forks_url":"https://api.github.com/repos/jelmnainen/exerking-front/forks","keys_url":"https://api.github.com/repos/jelmnainen/exerking-front/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jelmnainen/exerking-front/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jelmnainen/exerking-front/teams","hooks_url":"https://api.github.com/repos/jelmnainen/exerking-front/hooks","issue_events_url":"https://api.github.com/repos/jelmnainen/exerking-front/issues/events{/number}","events_url":"https://api.github.com/repos/jelmnainen/exerking-front/events","assignees_url":"https://api.github.com/repos/jelmnainen/exerking-front/assignees{/user}","branches_url":"https://api.github.com/repos/jelmnainen/exerking-front/branches{/branch}","tags_url":"https://api.github.com/repos/jelmnainen/exerking-front/tags","blobs_url":"https://api.github.com/repos/jelmnainen/exerking-front/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jelmnainen/exerking-front/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jelmnainen/exerking-front/git/refs{/sha}","trees_url":"https://api.github.com/repos/jelmnainen/exerking-front/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jelmnainen/exerking-front/statuses/{sha}","languages_url":"https://api.github.com/repos/jelmnainen/exerking-front/languages","stargazers_url":"https://api.github.com/repos/jelmnainen/exerking-front/stargazers","contributors_url":"https://api.github.com/repos/jelmnainen/exerking-front/contributors","subscribers_url":"https://api.github.com/repos/jelmnainen/exerking-front/subscribers","subscription_url":"https://api.github.com/repos/jelmnainen/exerking-front/subscription","commits_url":"https://api.github.com/repos/jelmnainen/exerking-front/commits{/sha}","git_commits_url":"https://api.github.com/repos/jelmnainen/exerking-front/git/commits{/sha}","comments_url":"https://api.github.com/repos/jelmnainen/exerking-front/comments{/number}","issue_comment_url":"https://api.github.com/repos/jelmnainen/exerking-front/issues/comments{/number}","contents_url":"https://api.github.com/repos/jelmnainen/exerking-front/contents/{+path}","compare_url":"https://api.github.com/repos/jelmnainen/exerking-front/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jelmnainen/exerking-front/merges","archive_url":"https://api.github.com/repos/jelmnainen/exerking-front/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jelmnainen/exerking-front/downloads","issues_url":"https://api.github.com/repos/jelmnainen/exerking-front/issues{/number}","pulls_url":"https://api.github.com/repos/jelmnainen/exerking-front/pulls{/number}","milestones_url":"https://api.github.com/repos/jelmnainen/exerking-front/milestones{/number}","notifications_url":"https://api.github.com/repos/jelmnainen/exerking-front/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jelmnainen/exerking-front/labels{/name}","releases_url":"https://api.github.com/repos/jelmnainen/exerking-front/releases{/id}","deployments_url":"https://api.github.com/repos/jelmnainen/exerking-front/deployments","created_at":"2016-01-19T15:20:04Z","updated_at":"2016-01-20T14:56:38Z","pushed_at":"2016-04-12T14:10:24Z","git_url":"git://github.com/jelmnainen/exerking-front.git","ssh_url":"git@github.com:jelmnainen/exerking-front.git","clone_url":"https://github.com/jelmnainen/exerking-front.git","svn_url":"https://github.com/jelmnainen/exerking-front","homepage":null,"size":187,"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":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"jelmnainen:master","ref":"master","sha":"2dd903ef331a20f97e69c625cde9501d8088cef7","user":{"login":"jelmnainen","id":5445441,"avatar_url":"https://avatars.githubusercontent.com/u/5445441?v=3","gravatar_id":"","url":"https://api.github.com/users/jelmnainen","html_url":"https://github.com/jelmnainen","followers_url":"https://api.github.com/users/jelmnainen/followers","following_url":"https://api.github.com/users/jelmnainen/following{/other_user}","gists_url":"https://api.github.com/users/jelmnainen/gists{/gist_id}","starred_url":"https://api.github.com/users/jelmnainen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jelmnainen/subscriptions","organizations_url":"https://api.github.com/users/jelmnainen/orgs","repos_url":"https://api.github.com/users/jelmnainen/repos","events_url":"https://api.github.com/users/jelmnainen/events{/privacy}","received_events_url":"https://api.github.com/users/jelmnainen/received_events","type":"User","site_admin":false},"repo":{"id":49961467,"name":"exerking-front","full_name":"jelmnainen/exerking-front","owner":{"login":"jelmnainen","id":5445441,"avatar_url":"https://avatars.githubusercontent.com/u/5445441?v=3","gravatar_id":"","url":"https://api.github.com/users/jelmnainen","html_url":"https://github.com/jelmnainen","followers_url":"https://api.github.com/users/jelmnainen/followers","following_url":"https://api.github.com/users/jelmnainen/following{/other_user}","gists_url":"https://api.github.com/users/jelmnainen/gists{/gist_id}","starred_url":"https://api.github.com/users/jelmnainen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jelmnainen/subscriptions","organizations_url":"https://api.github.com/users/jelmnainen/orgs","repos_url":"https://api.github.com/users/jelmnainen/repos","events_url":"https://api.github.com/users/jelmnainen/events{/privacy}","received_events_url":"https://api.github.com/users/jelmnainen/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jelmnainen/exerking-front","description":"An exercise marking system","fork":false,"url":"https://api.github.com/repos/jelmnainen/exerking-front","forks_url":"https://api.github.com/repos/jelmnainen/exerking-front/forks","keys_url":"https://api.github.com/repos/jelmnainen/exerking-front/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jelmnainen/exerking-front/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jelmnainen/exerking-front/teams","hooks_url":"https://api.github.com/repos/jelmnainen/exerking-front/hooks","issue_events_url":"https://api.github.com/repos/jelmnainen/exerking-front/issues/events{/number}","events_url":"https://api.github.com/repos/jelmnainen/exerking-front/events","assignees_url":"https://api.github.com/repos/jelmnainen/exerking-front/assignees{/user}","branches_url":"https://api.github.com/repos/jelmnainen/exerking-front/branches{/branch}","tags_url":"https://api.github.com/repos/jelmnainen/exerking-front/tags","blobs_url":"https://api.github.com/repos/jelmnainen/exerking-front/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jelmnainen/exerking-front/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jelmnainen/exerking-front/git/refs{/sha}","trees_url":"https://api.github.com/repos/jelmnainen/exerking-front/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jelmnainen/exerking-front/statuses/{sha}","languages_url":"https://api.github.com/repos/jelmnainen/exerking-front/languages","stargazers_url":"https://api.github.com/repos/jelmnainen/exerking-front/stargazers","contributors_url":"https://api.github.com/repos/jelmnainen/exerking-front/contributors","subscribers_url":"https://api.github.com/repos/jelmnainen/exerking-front/subscribers","subscription_url":"https://api.github.com/repos/jelmnainen/exerking-front/subscription","commits_url":"https://api.github.com/repos/jelmnainen/exerking-front/commits{/sha}","git_commits_url":"https://api.github.com/repos/jelmnainen/exerking-front/git/commits{/sha}","comments_url":"https://api.github.com/repos/jelmnainen/exerking-front/comments{/number}","issue_comment_url":"https://api.github.com/repos/jelmnainen/exerking-front/issues/comments{/number}","contents_url":"https://api.github.com/repos/jelmnainen/exerking-front/contents/{+path}","compare_url":"https://api.github.com/repos/jelmnainen/exerking-front/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jelmnainen/exerking-front/merges","archive_url":"https://api.github.com/repos/jelmnainen/exerking-front/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jelmnainen/exerking-front/downloads","issues_url":"https://api.github.com/repos/jelmnainen/exerking-front/issues{/number}","pulls_url":"https://api.github.com/repos/jelmnainen/exerking-front/pulls{/number}","milestones_url":"https://api.github.com/repos/jelmnainen/exerking-front/milestones{/number}","notifications_url":"https://api.github.com/repos/jelmnainen/exerking-front/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jelmnainen/exerking-front/labels{/name}","releases_url":"https://api.github.com/repos/jelmnainen/exerking-front/releases{/id}","deployments_url":"https://api.github.com/repos/jelmnainen/exerking-front/deployments","created_at":"2016-01-19T15:20:04Z","updated_at":"2016-01-20T14:56:38Z","pushed_at":"2016-04-12T14:10:24Z","git_url":"git://github.com/jelmnainen/exerking-front.git","ssh_url":"git@github.com:jelmnainen/exerking-front.git","clone_url":"https://github.com/jelmnainen/exerking-front.git","svn_url":"https://github.com/jelmnainen/exerking-front","homepage":null,"size":187,"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":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/jelmnainen/exerking-front/pulls/63"},"html":{"href":"https://github.com/jelmnainen/exerking-front/pull/63"},"issue":{"href":"https://api.github.com/repos/jelmnainen/exerking-front/issues/63"},"comments":{"href":"https://api.github.com/repos/jelmnainen/exerking-front/issues/63/comments"},"review_comments":{"href":"https://api.github.com/repos/jelmnainen/exerking-front/pulls/63/comments"},"review_comment":{"href":"https://api.github.com/repos/jelmnainen/exerking-front/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/jelmnainen/exerking-front/pulls/63/commits"},"statuses":{"href":"https://api.github.com/repos/jelmnainen/exerking-front/statuses/84fdab106174e0df98266c14121b478703e66144"}}}}