{"action":"created","comment":{"url":"https://api.github.com/repos/choice-open/playground/pulls/comments/125159952","pull_request_review_id":47527319,"id":125159952,"diff_hunk":"@@ -0,0 +1,51 @@\n+defmodule Playground.V1.ResultController do\n+  use Playground.Web, :controller\n+\n+  alias Playground.Answer\n+  alias Playground.Result\n+  alias Playground.Question\n+  alias Playground.Repo\n+  alias Playground.HelpFunc\n+  import Ecto.Query\n+\n+  @doc \"\"\"\n+  ## HTTP Verb and URL\n+  GET /v1/surveys/:survey_id/results\n+\n+  ### 返回指定问卷的所有答案\n+  \"\"\"\n+  def index(conn, params) do\n+    calculate(params[\"survey_id\"])\n+    results = HelpFunc.get_result(params[\"survey_id\"])\n+    render conn, \"index.json\", %{data: results, total: get_total_count(params[\"survey_id\"])}\n+  end\n+  \n+  @doc \"\"\"\n+  ## HTTP Verb and URL\n+  GET /v1/surveys/:survey_id/results/:position\n+\n+  ### 返回指定问卷的指定问题答案，参数为问卷题号\n+  \"\"\"\n+  def show(conn, params) do\n+    calculate(params[\"survey_id\"], params[\"id\"])\n+    results = HelpFunc.get_result(params[\"survey_id\"], params[\"id\"])\n+    render conn, \"show.json\", %{data: results, total: get_total_count(params[\"survey_id\"])}\n+  end\n+\n+  defp calculate(survey) do\n+    HelpFunc.delete_result(survey)\n+    HelpFunc.start(survey)\n+  end\n+\n+  defp calculate(survey, position) do\n+    HelpFunc.delete_result(survey, position)\n+    HelpFunc.start(survey, position)\n+  end\n+","path":"web/controllers/v1/result_controller.ex","position":39,"original_position":44,"commit_id":"6e2a63630f069b9b9c95c6ba610e30d796c47a10","original_commit_id":"ba013114ca451da6e72083794fa236f28a3630a2","user":{"login":"darkbaby123","id":2097309,"avatar_url":"https://avatars3.githubusercontent.com/u/2097309?v=3","gravatar_id":"","url":"https://api.github.com/users/darkbaby123","html_url":"https://github.com/darkbaby123","followers_url":"https://api.github.com/users/darkbaby123/followers","following_url":"https://api.github.com/users/darkbaby123/following{/other_user}","gists_url":"https://api.github.com/users/darkbaby123/gists{/gist_id}","starred_url":"https://api.github.com/users/darkbaby123/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/darkbaby123/subscriptions","organizations_url":"https://api.github.com/users/darkbaby123/orgs","repos_url":"https://api.github.com/users/darkbaby123/repos","events_url":"https://api.github.com/users/darkbaby123/events{/privacy}","received_events_url":"https://api.github.com/users/darkbaby123/received_events","type":"User","site_admin":false},"body":"这里的问题不是应不应该写成 Plug ，而是为什么一定要 delete 然后 create 呢？","created_at":"2017-07-01T10:19:13Z","updated_at":"2017-07-01T10:50:28Z","html_url":"https://github.com/choice-open/playground/pull/4#discussion_r125159952","pull_request_url":"https://api.github.com/repos/choice-open/playground/pulls/4","_links":{"self":{"href":"https://api.github.com/repos/choice-open/playground/pulls/comments/125159952"},"html":{"href":"https://github.com/choice-open/playground/pull/4#discussion_r125159952"},"pull_request":{"href":"https://api.github.com/repos/choice-open/playground/pulls/4"}}},"pull_request":{"url":"https://api.github.com/repos/choice-open/playground/pulls/4","id":128184886,"html_url":"https://github.com/choice-open/playground/pull/4","diff_url":"https://github.com/choice-open/playground/pull/4.diff","patch_url":"https://github.com/choice-open/playground/pull/4.patch","issue_url":"https://api.github.com/repos/choice-open/playground/issues/4","number":4,"state":"open","locked":false,"title":"Develop","user":{"login":"smartepsh","id":3273295,"avatar_url":"https://avatars3.githubusercontent.com/u/3273295?v=3","gravatar_id":"","url":"https://api.github.com/users/smartepsh","html_url":"https://github.com/smartepsh","followers_url":"https://api.github.com/users/smartepsh/followers","following_url":"https://api.github.com/users/smartepsh/following{/other_user}","gists_url":"https://api.github.com/users/smartepsh/gists{/gist_id}","starred_url":"https://api.github.com/users/smartepsh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smartepsh/subscriptions","organizations_url":"https://api.github.com/users/smartepsh/orgs","repos_url":"https://api.github.com/users/smartepsh/repos","events_url":"https://api.github.com/users/smartepsh/events{/privacy}","received_events_url":"https://api.github.com/users/smartepsh/received_events","type":"User","site_admin":false},"body":"测试实在无能……看了 @Cifer-Y 的版本，感觉他的结构好方便，测试里随拿随用……\r\n\r\n我还是偏向做一些辅助字段，查询的时候不用载入关联结构，毕竟提交过的答案，是不会因为题目改变而改变的……","created_at":"2017-06-29T15:44:09Z","updated_at":"2017-07-01T10:50:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"698b22420b9efd3a3d9e1833cd6126af419e8e07","assignee":null,"assignees":[],"requested_reviewers":[{"login":"nightire","id":1104018,"avatar_url":"https://avatars0.githubusercontent.com/u/1104018?v=3","gravatar_id":"","url":"https://api.github.com/users/nightire","html_url":"https://github.com/nightire","followers_url":"https://api.github.com/users/nightire/followers","following_url":"https://api.github.com/users/nightire/following{/other_user}","gists_url":"https://api.github.com/users/nightire/gists{/gist_id}","starred_url":"https://api.github.com/users/nightire/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nightire/subscriptions","organizations_url":"https://api.github.com/users/nightire/orgs","repos_url":"https://api.github.com/users/nightire/repos","events_url":"https://api.github.com/users/nightire/events{/privacy}","received_events_url":"https://api.github.com/users/nightire/received_events","type":"User","site_admin":false},{"login":"Cifer-Y","id":4470516,"avatar_url":"https://avatars3.githubusercontent.com/u/4470516?v=3","gravatar_id":"","url":"https://api.github.com/users/Cifer-Y","html_url":"https://github.com/Cifer-Y","followers_url":"https://api.github.com/users/Cifer-Y/followers","following_url":"https://api.github.com/users/Cifer-Y/following{/other_user}","gists_url":"https://api.github.com/users/Cifer-Y/gists{/gist_id}","starred_url":"https://api.github.com/users/Cifer-Y/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Cifer-Y/subscriptions","organizations_url":"https://api.github.com/users/Cifer-Y/orgs","repos_url":"https://api.github.com/users/Cifer-Y/repos","events_url":"https://api.github.com/users/Cifer-Y/events{/privacy}","received_events_url":"https://api.github.com/users/Cifer-Y/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/choice-open/playground/pulls/4/commits","review_comments_url":"https://api.github.com/repos/choice-open/playground/pulls/4/comments","review_comment_url":"https://api.github.com/repos/choice-open/playground/pulls/comments{/number}","comments_url":"https://api.github.com/repos/choice-open/playground/issues/4/comments","statuses_url":"https://api.github.com/repos/choice-open/playground/statuses/6e2a63630f069b9b9c95c6ba610e30d796c47a10","head":{"label":"smartepsh:develop","ref":"develop","sha":"6e2a63630f069b9b9c95c6ba610e30d796c47a10","user":{"login":"smartepsh","id":3273295,"avatar_url":"https://avatars3.githubusercontent.com/u/3273295?v=3","gravatar_id":"","url":"https://api.github.com/users/smartepsh","html_url":"https://github.com/smartepsh","followers_url":"https://api.github.com/users/smartepsh/followers","following_url":"https://api.github.com/users/smartepsh/following{/other_user}","gists_url":"https://api.github.com/users/smartepsh/gists{/gist_id}","starred_url":"https://api.github.com/users/smartepsh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smartepsh/subscriptions","organizations_url":"https://api.github.com/users/smartepsh/orgs","repos_url":"https://api.github.com/users/smartepsh/repos","events_url":"https://api.github.com/users/smartepsh/events{/privacy}","received_events_url":"https://api.github.com/users/smartepsh/received_events","type":"User","site_admin":false},"repo":{"id":94190494,"name":"playground","full_name":"smartepsh/playground","owner":{"login":"smartepsh","id":3273295,"avatar_url":"https://avatars3.githubusercontent.com/u/3273295?v=3","gravatar_id":"","url":"https://api.github.com/users/smartepsh","html_url":"https://github.com/smartepsh","followers_url":"https://api.github.com/users/smartepsh/followers","following_url":"https://api.github.com/users/smartepsh/following{/other_user}","gists_url":"https://api.github.com/users/smartepsh/gists{/gist_id}","starred_url":"https://api.github.com/users/smartepsh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smartepsh/subscriptions","organizations_url":"https://api.github.com/users/smartepsh/orgs","repos_url":"https://api.github.com/users/smartepsh/repos","events_url":"https://api.github.com/users/smartepsh/events{/privacy}","received_events_url":"https://api.github.com/users/smartepsh/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/smartepsh/playground","description":null,"fork":true,"url":"https://api.github.com/repos/smartepsh/playground","forks_url":"https://api.github.com/repos/smartepsh/playground/forks","keys_url":"https://api.github.com/repos/smartepsh/playground/keys{/key_id}","collaborators_url":"https://api.github.com/repos/smartepsh/playground/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/smartepsh/playground/teams","hooks_url":"https://api.github.com/repos/smartepsh/playground/hooks","issue_events_url":"https://api.github.com/repos/smartepsh/playground/issues/events{/number}","events_url":"https://api.github.com/repos/smartepsh/playground/events","assignees_url":"https://api.github.com/repos/smartepsh/playground/assignees{/user}","branches_url":"https://api.github.com/repos/smartepsh/playground/branches{/branch}","tags_url":"https://api.github.com/repos/smartepsh/playground/tags","blobs_url":"https://api.github.com/repos/smartepsh/playground/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/smartepsh/playground/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/smartepsh/playground/git/refs{/sha}","trees_url":"https://api.github.com/repos/smartepsh/playground/git/trees{/sha}","statuses_url":"https://api.github.com/repos/smartepsh/playground/statuses/{sha}","languages_url":"https://api.github.com/repos/smartepsh/playground/languages","stargazers_url":"https://api.github.com/repos/smartepsh/playground/stargazers","contributors_url":"https://api.github.com/repos/smartepsh/playground/contributors","subscribers_url":"https://api.github.com/repos/smartepsh/playground/subscribers","subscription_url":"https://api.github.com/repos/smartepsh/playground/subscription","commits_url":"https://api.github.com/repos/smartepsh/playground/commits{/sha}","git_commits_url":"https://api.github.com/repos/smartepsh/playground/git/commits{/sha}","comments_url":"https://api.github.com/repos/smartepsh/playground/comments{/number}","issue_comment_url":"https://api.github.com/repos/smartepsh/playground/issues/comments{/number}","contents_url":"https://api.github.com/repos/smartepsh/playground/contents/{+path}","compare_url":"https://api.github.com/repos/smartepsh/playground/compare/{base}...{head}","merges_url":"https://api.github.com/repos/smartepsh/playground/merges","archive_url":"https://api.github.com/repos/smartepsh/playground/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/smartepsh/playground/downloads","issues_url":"https://api.github.com/repos/smartepsh/playground/issues{/number}","pulls_url":"https://api.github.com/repos/smartepsh/playground/pulls{/number}","milestones_url":"https://api.github.com/repos/smartepsh/playground/milestones{/number}","notifications_url":"https://api.github.com/repos/smartepsh/playground/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/smartepsh/playground/labels{/name}","releases_url":"https://api.github.com/repos/smartepsh/playground/releases{/id}","deployments_url":"https://api.github.com/repos/smartepsh/playground/deployments","created_at":"2017-06-13T08:39:46Z","updated_at":"2017-06-13T05:48:26Z","pushed_at":"2017-06-29T17:42:17Z","git_url":"git://github.com/smartepsh/playground.git","ssh_url":"git@github.com:smartepsh/playground.git","clone_url":"https://github.com/smartepsh/playground.git","svn_url":"https://github.com/smartepsh/playground","homepage":null,"size":72,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"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":"choice-open:master","ref":"master","sha":"b14ae0354b0023df9fa74a3e06c6c8f5f14089a0","user":{"login":"choice-open","id":29393846,"avatar_url":"https://avatars3.githubusercontent.com/u/29393846?v=3","gravatar_id":"","url":"https://api.github.com/users/choice-open","html_url":"https://github.com/choice-open","followers_url":"https://api.github.com/users/choice-open/followers","following_url":"https://api.github.com/users/choice-open/following{/other_user}","gists_url":"https://api.github.com/users/choice-open/gists{/gist_id}","starred_url":"https://api.github.com/users/choice-open/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/choice-open/subscriptions","organizations_url":"https://api.github.com/users/choice-open/orgs","repos_url":"https://api.github.com/users/choice-open/repos","events_url":"https://api.github.com/users/choice-open/events{/privacy}","received_events_url":"https://api.github.com/users/choice-open/received_events","type":"Organization","site_admin":false},"repo":{"id":94174120,"name":"playground","full_name":"choice-open/playground","owner":{"login":"choice-open","id":29393846,"avatar_url":"https://avatars3.githubusercontent.com/u/29393846?v=3","gravatar_id":"","url":"https://api.github.com/users/choice-open","html_url":"https://github.com/choice-open","followers_url":"https://api.github.com/users/choice-open/followers","following_url":"https://api.github.com/users/choice-open/following{/other_user}","gists_url":"https://api.github.com/users/choice-open/gists{/gist_id}","starred_url":"https://api.github.com/users/choice-open/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/choice-open/subscriptions","organizations_url":"https://api.github.com/users/choice-open/orgs","repos_url":"https://api.github.com/users/choice-open/repos","events_url":"https://api.github.com/users/choice-open/events{/privacy}","received_events_url":"https://api.github.com/users/choice-open/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/choice-open/playground","description":null,"fork":false,"url":"https://api.github.com/repos/choice-open/playground","forks_url":"https://api.github.com/repos/choice-open/playground/forks","keys_url":"https://api.github.com/repos/choice-open/playground/keys{/key_id}","collaborators_url":"https://api.github.com/repos/choice-open/playground/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/choice-open/playground/teams","hooks_url":"https://api.github.com/repos/choice-open/playground/hooks","issue_events_url":"https://api.github.com/repos/choice-open/playground/issues/events{/number}","events_url":"https://api.github.com/repos/choice-open/playground/events","assignees_url":"https://api.github.com/repos/choice-open/playground/assignees{/user}","branches_url":"https://api.github.com/repos/choice-open/playground/branches{/branch}","tags_url":"https://api.github.com/repos/choice-open/playground/tags","blobs_url":"https://api.github.com/repos/choice-open/playground/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/choice-open/playground/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/choice-open/playground/git/refs{/sha}","trees_url":"https://api.github.com/repos/choice-open/playground/git/trees{/sha}","statuses_url":"https://api.github.com/repos/choice-open/playground/statuses/{sha}","languages_url":"https://api.github.com/repos/choice-open/playground/languages","stargazers_url":"https://api.github.com/repos/choice-open/playground/stargazers","contributors_url":"https://api.github.com/repos/choice-open/playground/contributors","subscribers_url":"https://api.github.com/repos/choice-open/playground/subscribers","subscription_url":"https://api.github.com/repos/choice-open/playground/subscription","commits_url":"https://api.github.com/repos/choice-open/playground/commits{/sha}","git_commits_url":"https://api.github.com/repos/choice-open/playground/git/commits{/sha}","comments_url":"https://api.github.com/repos/choice-open/playground/comments{/number}","issue_comment_url":"https://api.github.com/repos/choice-open/playground/issues/comments{/number}","contents_url":"https://api.github.com/repos/choice-open/playground/contents/{+path}","compare_url":"https://api.github.com/repos/choice-open/playground/compare/{base}...{head}","merges_url":"https://api.github.com/repos/choice-open/playground/merges","archive_url":"https://api.github.com/repos/choice-open/playground/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/choice-open/playground/downloads","issues_url":"https://api.github.com/repos/choice-open/playground/issues{/number}","pulls_url":"https://api.github.com/repos/choice-open/playground/pulls{/number}","milestones_url":"https://api.github.com/repos/choice-open/playground/milestones{/number}","notifications_url":"https://api.github.com/repos/choice-open/playground/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/choice-open/playground/labels{/name}","releases_url":"https://api.github.com/repos/choice-open/playground/releases{/id}","deployments_url":"https://api.github.com/repos/choice-open/playground/deployments","created_at":"2017-06-13T05:48:13Z","updated_at":"2017-06-19T11:21:58Z","pushed_at":"2017-06-29T17:42:18Z","git_url":"git://github.com/choice-open/playground.git","ssh_url":"git@github.com:choice-open/playground.git","clone_url":"https://github.com/choice-open/playground.git","svn_url":"https://github.com/choice-open/playground","homepage":null,"size":2,"stargazers_count":1,"watchers_count":1,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":2,"forks":3,"open_issues":2,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/choice-open/playground/pulls/4"},"html":{"href":"https://github.com/choice-open/playground/pull/4"},"issue":{"href":"https://api.github.com/repos/choice-open/playground/issues/4"},"comments":{"href":"https://api.github.com/repos/choice-open/playground/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/choice-open/playground/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/choice-open/playground/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/choice-open/playground/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/choice-open/playground/statuses/6e2a63630f069b9b9c95c6ba610e30d796c47a10"}}}}
{"actor":{"display_login":"darkbaby123"}}