{"action":"created","comment":{"url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/pulls/comments/63217165","id":63217165,"diff_hunk":"@@ -0,0 +1,153 @@\n+(function() {\n+  'use strict';\n+  angular.module('PDRClient')\n+      .service('ConsensusService', ConsensusService);\n+\n+  ConsensusService.$inject = [\n+    '$stateParams',\n+    '$location',\n+    '$q',\n+    'Consensus',\n+    'AnalysisConsensus',\n+    'AnalysisResponse',\n+    'Score',\n+    'AnalysisConsensusScore',\n+    'ProductEntry',\n+    'DataEntry'\n+  ];\n+\n+  function ConsensusService($stateParams, $location, $q, Consensus, AnalysisConsensus, AnalysisResponse, Score, AnalysisConsensusScore, ProductEntry, DataEntry) {\n+    var service = this;\n+\n+    service.setContext = function(context) {\n+      service.context = context;\n+      return service;\n+    };\n+\n+    service.extractId = function() {\n+      return $stateParams.assessment_id || $stateParams.analysis_id;\n+    };\n+\n+    service.redirectToIndex = function () {\n+      if (service.context === \"assessment\") {\n+        $location.path(\"/assessments\");\n+      } else if (service.context === \"analysis\") {\n+        $location.path(\"/inventories/\" + $stateParams.inventory_id + \"/analyses\");\n+      }\n+    };\n+\n+    service.redirectToReport = function () {\n+      if (service.context === \"assessment\") {\n+        $location.path(\"/assessments/\" + service.extractId() + \"/report\");\n+      } else if (service.context === \"analysis\") {\n+        $location.path(\"/inventories/\" + $stateParams.inventory_id + \"/analyses/\" + service.extractId() + \"/report\");\n+      }\n+    };\n+\n+    service.redirectToCreatedConsensus = function (consensusId) {\n+      if (service.context === \"assessment\") {\n+        $location.path(\"/assessments/\" + service.extractId() + \"/consensus/\" + consensusId);\n+      } else if (service.context === \"analysis\") {\n+        $location.path(\"/inventories/\" + $stateParams.inventory_id + \"/analyses/\" + service.extractId() + \"/consensus/\" + consensusId);\n+      }\n+    };\n+\n+    service.createConsensus = function () {\n+      if (service.context === \"assessment\") {\n+        return Consensus.create({\n+          assessment_id: service.extractId()\n+        }, {}).$promise;\n+      } else if (service.context === \"analysis\") {\n+        return AnalysisResponse.save({\n+          inventory_id: $stateParams.inventory_id,\n+          analysis_id: service.extractId()\n+        }, {}).$promise\n+        .then(function () {\n+          return AnalysisConsensus.create({\n+            inventory_id: $stateParams.inventory_id,\n+            analysis_id: service.extractId()\n+          }, {}).$promise;\n+        });\n+      }","path":"app/assets/javascripts/client/consensus/ConsensusService.js","position":71,"original_position":71,"commit_id":"95d80f8927ed1d6e7496e59524a35b047cc546f9","original_commit_id":"aeb20c8a03d429988a376620f55b8138842d2895","user":{"login":"MakotoTheKnight","id":1821302,"avatar_url":"https://avatars.githubusercontent.com/u/1821302?v=3","gravatar_id":"","url":"https://api.github.com/users/MakotoTheKnight","html_url":"https://github.com/MakotoTheKnight","followers_url":"https://api.github.com/users/MakotoTheKnight/followers","following_url":"https://api.github.com/users/MakotoTheKnight/following{/other_user}","gists_url":"https://api.github.com/users/MakotoTheKnight/gists{/gist_id}","starred_url":"https://api.github.com/users/MakotoTheKnight/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MakotoTheKnight/subscriptions","organizations_url":"https://api.github.com/users/MakotoTheKnight/orgs","repos_url":"https://api.github.com/users/MakotoTheKnight/repos","events_url":"https://api.github.com/users/MakotoTheKnight/events{/privacy}","received_events_url":"https://api.github.com/users/MakotoTheKnight/received_events","type":"User","site_admin":false},"body":"@juliosantos:  Not an immediate focus, but good to keep in the back of our minds.","created_at":"2016-05-13T17:06:54Z","updated_at":"2016-05-13T17:06:54Z","html_url":"https://github.com/MobilityLabs/pdredesign-server/pull/306#discussion_r63217165","pull_request_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/pulls/306","_links":{"self":{"href":"https://api.github.com/repos/MobilityLabs/pdredesign-server/pulls/comments/63217165"},"html":{"href":"https://github.com/MobilityLabs/pdredesign-server/pull/306#discussion_r63217165"},"pull_request":{"href":"https://api.github.com/repos/MobilityLabs/pdredesign-server/pulls/306"}}},"pull_request":{"url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/pulls/306","id":69545765,"html_url":"https://github.com/MobilityLabs/pdredesign-server/pull/306","diff_url":"https://github.com/MobilityLabs/pdredesign-server/pull/306.diff","patch_url":"https://github.com/MobilityLabs/pdredesign-server/pull/306.patch","issue_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/issues/306","number":306,"state":"open","locked":false,"title":"Closes #267: Analysis consensus frontend partial","user":{"login":"juliosantos","id":365821,"avatar_url":"https://avatars.githubusercontent.com/u/365821?v=3","gravatar_id":"","url":"https://api.github.com/users/juliosantos","html_url":"https://github.com/juliosantos","followers_url":"https://api.github.com/users/juliosantos/followers","following_url":"https://api.github.com/users/juliosantos/following{/other_user}","gists_url":"https://api.github.com/users/juliosantos/gists{/gist_id}","starred_url":"https://api.github.com/users/juliosantos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juliosantos/subscriptions","organizations_url":"https://api.github.com/users/juliosantos/orgs","repos_url":"https://api.github.com/users/juliosantos/repos","events_url":"https://api.github.com/users/juliosantos/events{/privacy}","received_events_url":"https://api.github.com/users/juliosantos/received_events","type":"User","site_admin":false},"body":"Since there is no analysis list from where to generate/view a consensus, in order to test this,\r\n\r\n0. Create an analysis on an inventory\r\n0. Create the consensus for that analysis by navigating to `inventories/:inventory_id/analyses/:analysis_id/consensus`\r\n0. The consensus should be created and you should be redirected to `inventories/:inventory_id/analyses/:analysis_id/consensus/:consensus_id`","created_at":"2016-05-10T17:29:28Z","updated_at":"2016-05-13T17:06:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3097101c09195cdca1e23c890fbc88f70bbe5389","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/pulls/306/commits","review_comments_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/pulls/306/comments","review_comment_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/pulls/comments{/number}","comments_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/issues/306/comments","statuses_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/statuses/95d80f8927ed1d6e7496e59524a35b047cc546f9","head":{"label":"MobilityLabs:267-analysis-consensus-frontend-partial","ref":"267-analysis-consensus-frontend-partial","sha":"95d80f8927ed1d6e7496e59524a35b047cc546f9","user":{"login":"MobilityLabs","id":6536866,"avatar_url":"https://avatars.githubusercontent.com/u/6536866?v=3","gravatar_id":"","url":"https://api.github.com/users/MobilityLabs","html_url":"https://github.com/MobilityLabs","followers_url":"https://api.github.com/users/MobilityLabs/followers","following_url":"https://api.github.com/users/MobilityLabs/following{/other_user}","gists_url":"https://api.github.com/users/MobilityLabs/gists{/gist_id}","starred_url":"https://api.github.com/users/MobilityLabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MobilityLabs/subscriptions","organizations_url":"https://api.github.com/users/MobilityLabs/orgs","repos_url":"https://api.github.com/users/MobilityLabs/repos","events_url":"https://api.github.com/users/MobilityLabs/events{/privacy}","received_events_url":"https://api.github.com/users/MobilityLabs/received_events","type":"Organization","site_admin":false},"repo":{"id":19004072,"name":"pdredesign-server","full_name":"MobilityLabs/pdredesign-server","owner":{"login":"MobilityLabs","id":6536866,"avatar_url":"https://avatars.githubusercontent.com/u/6536866?v=3","gravatar_id":"","url":"https://api.github.com/users/MobilityLabs","html_url":"https://github.com/MobilityLabs","followers_url":"https://api.github.com/users/MobilityLabs/followers","following_url":"https://api.github.com/users/MobilityLabs/following{/other_user}","gists_url":"https://api.github.com/users/MobilityLabs/gists{/gist_id}","starred_url":"https://api.github.com/users/MobilityLabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MobilityLabs/subscriptions","organizations_url":"https://api.github.com/users/MobilityLabs/orgs","repos_url":"https://api.github.com/users/MobilityLabs/repos","events_url":"https://api.github.com/users/MobilityLabs/events{/privacy}","received_events_url":"https://api.github.com/users/MobilityLabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/MobilityLabs/pdredesign-server","description":"PDRedesign api server","fork":false,"url":"https://api.github.com/repos/MobilityLabs/pdredesign-server","forks_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/forks","keys_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/teams","hooks_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/hooks","issue_events_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/issues/events{/number}","events_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/events","assignees_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/assignees{/user}","branches_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/branches{/branch}","tags_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/tags","blobs_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/statuses/{sha}","languages_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/languages","stargazers_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/stargazers","contributors_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/contributors","subscribers_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/subscribers","subscription_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/subscription","commits_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/contents/{+path}","compare_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/merges","archive_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/downloads","issues_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/issues{/number}","pulls_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/pulls{/number}","milestones_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/milestones{/number}","notifications_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/labels{/name}","releases_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/releases{/id}","deployments_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/deployments","created_at":"2014-04-21T19:25:52Z","updated_at":"2016-04-18T16:11:52Z","pushed_at":"2016-05-13T15:29:45Z","git_url":"git://github.com/MobilityLabs/pdredesign-server.git","ssh_url":"git@github.com:MobilityLabs/pdredesign-server.git","clone_url":"https://github.com/MobilityLabs/pdredesign-server.git","svn_url":"https://github.com/MobilityLabs/pdredesign-server","homepage":null,"size":61312,"stargazers_count":1,"watchers_count":1,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":81,"forks":0,"open_issues":81,"watchers":1,"default_branch":"master"}},"base":{"label":"MobilityLabs:staging","ref":"staging","sha":"5d72e4772169d8468d60d770cd2c999b3581b3a8","user":{"login":"MobilityLabs","id":6536866,"avatar_url":"https://avatars.githubusercontent.com/u/6536866?v=3","gravatar_id":"","url":"https://api.github.com/users/MobilityLabs","html_url":"https://github.com/MobilityLabs","followers_url":"https://api.github.com/users/MobilityLabs/followers","following_url":"https://api.github.com/users/MobilityLabs/following{/other_user}","gists_url":"https://api.github.com/users/MobilityLabs/gists{/gist_id}","starred_url":"https://api.github.com/users/MobilityLabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MobilityLabs/subscriptions","organizations_url":"https://api.github.com/users/MobilityLabs/orgs","repos_url":"https://api.github.com/users/MobilityLabs/repos","events_url":"https://api.github.com/users/MobilityLabs/events{/privacy}","received_events_url":"https://api.github.com/users/MobilityLabs/received_events","type":"Organization","site_admin":false},"repo":{"id":19004072,"name":"pdredesign-server","full_name":"MobilityLabs/pdredesign-server","owner":{"login":"MobilityLabs","id":6536866,"avatar_url":"https://avatars.githubusercontent.com/u/6536866?v=3","gravatar_id":"","url":"https://api.github.com/users/MobilityLabs","html_url":"https://github.com/MobilityLabs","followers_url":"https://api.github.com/users/MobilityLabs/followers","following_url":"https://api.github.com/users/MobilityLabs/following{/other_user}","gists_url":"https://api.github.com/users/MobilityLabs/gists{/gist_id}","starred_url":"https://api.github.com/users/MobilityLabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MobilityLabs/subscriptions","organizations_url":"https://api.github.com/users/MobilityLabs/orgs","repos_url":"https://api.github.com/users/MobilityLabs/repos","events_url":"https://api.github.com/users/MobilityLabs/events{/privacy}","received_events_url":"https://api.github.com/users/MobilityLabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/MobilityLabs/pdredesign-server","description":"PDRedesign api server","fork":false,"url":"https://api.github.com/repos/MobilityLabs/pdredesign-server","forks_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/forks","keys_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/teams","hooks_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/hooks","issue_events_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/issues/events{/number}","events_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/events","assignees_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/assignees{/user}","branches_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/branches{/branch}","tags_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/tags","blobs_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/statuses/{sha}","languages_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/languages","stargazers_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/stargazers","contributors_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/contributors","subscribers_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/subscribers","subscription_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/subscription","commits_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/contents/{+path}","compare_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/merges","archive_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/downloads","issues_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/issues{/number}","pulls_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/pulls{/number}","milestones_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/milestones{/number}","notifications_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/labels{/name}","releases_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/releases{/id}","deployments_url":"https://api.github.com/repos/MobilityLabs/pdredesign-server/deployments","created_at":"2014-04-21T19:25:52Z","updated_at":"2016-04-18T16:11:52Z","pushed_at":"2016-05-13T15:29:45Z","git_url":"git://github.com/MobilityLabs/pdredesign-server.git","ssh_url":"git@github.com:MobilityLabs/pdredesign-server.git","clone_url":"https://github.com/MobilityLabs/pdredesign-server.git","svn_url":"https://github.com/MobilityLabs/pdredesign-server","homepage":null,"size":61312,"stargazers_count":1,"watchers_count":1,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":81,"forks":0,"open_issues":81,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/MobilityLabs/pdredesign-server/pulls/306"},"html":{"href":"https://github.com/MobilityLabs/pdredesign-server/pull/306"},"issue":{"href":"https://api.github.com/repos/MobilityLabs/pdredesign-server/issues/306"},"comments":{"href":"https://api.github.com/repos/MobilityLabs/pdredesign-server/issues/306/comments"},"review_comments":{"href":"https://api.github.com/repos/MobilityLabs/pdredesign-server/pulls/306/comments"},"review_comment":{"href":"https://api.github.com/repos/MobilityLabs/pdredesign-server/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/MobilityLabs/pdredesign-server/pulls/306/commits"},"statuses":{"href":"https://api.github.com/repos/MobilityLabs/pdredesign-server/statuses/95d80f8927ed1d6e7496e59524a35b047cc546f9"}}}}