{"action":"created","comment":{"url":"https://api.github.com/repos/plauring/review-site-8/pulls/comments/83222418","pull_request_review_id":4078731,"id":83222418,"diff_hunk":"@@ -13,32 +13,96 @@ def new\n     end\n   end\n \n- def create\n-   @devtool = Devtool.find(params[:devtool_id])\n-   @review = Review.new(review_params)\n-   @review.devtool = @devtool\n-\n-   if @review.save\n-      flash[:notice] = 'Review added successfully'\n-      redirect_to devtool_path(@devtool)\n-   else\n-      flash[:notice] = @review.errors.full_messages.join(',')\n+  def create\n+    @devtool = Devtool.find(params[:devtool_id])\n+    @review = Review.new(review_params)\n+    @review.devtool = @devtool\n+     if @review.save\n+      flash[:notice] = \"Review added successfully\"\n+        redirect_to devtool_path(@devtool)\n+     else\n+      flash[:notice] = @review.errors.full_messages.join(\",\")\n       render :new\n-   end\n- end\n-\n- def destroy\n-   @devtool = Devtool.find(params[:id])\n-   @reviews = Review.all\n-   @reviews.each do |review|\n-     if review.destroy\n+     end\n+  end\n+\n+  def upvote\n+    @review = Review.find(params[:id])\n+      @users = current_user\n+      @user = @users.id\n+    if Vote.find_by(user_id: @user, review_id: @review.id).nil?\n+      Vote.create(user_id: @user, review_id: @review.id, status: true)\n+    else\n+      if Vote.find_by(user_id: @user, review_id: @review.id).status == true\n+        @upvote2 = Vote.find_by(user_id: @user, review_id: @review.id)\n+        @upvote2.destroy\n+      else\n+        Vote.find_by(user_id: @user, review_id: @review.id).update(status: true)\n+      end\n+    end\n+\n+    @votes_for_review = @review.votes\n+    @upvote_count = []\n+    @downvote_count = []\n+\n+      @votes_for_review.each do |vote|\n+        if vote.status == true\n+          @upvote_count << vote\n+        else\n+          @downvote_count << vote\n+        end\n+      end\n+\n+      respond_to do |format|\n+        format.html { redirect_to :back }\n+        format.json { render :json => { upvotes: @upvote_count.length, downvotes: @downvote_count.length, sumvotes: (@upvote_count.length - @downvote_count.length) } }\n+        format.js\n+      end\n+  end\n+\n+  def downvote\n+    @review = Review.find(params[:id])\n+    @users = current_user\n+    @user = @users.id\n+      if Vote.find_by(user_id: @user, review_id: @review.id).nil?\n+        Vote.create(user_id: @user, review_id: @review.id, status: false)\n+      else\n+        if Vote.find_by(user_id: @user, review_id: @review.id).status == false","path":"app/controllers/reviews_controller.rb","position":83,"original_position":83,"commit_id":"0b01fefeffb6dc24ef701bbb2ef16d35ca4d0ac6","original_commit_id":"0b01fefeffb6dc24ef701bbb2ef16d35ca4d0ac6","user":{"login":"houndci-bot","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci-bot","html_url":"https://github.com/houndci-bot","followers_url":"https://api.github.com/users/houndci-bot/followers","following_url":"https://api.github.com/users/houndci-bot/following{/other_user}","gists_url":"https://api.github.com/users/houndci-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci-bot/subscriptions","organizations_url":"https://api.github.com/users/houndci-bot/orgs","repos_url":"https://api.github.com/users/houndci-bot/repos","events_url":"https://api.github.com/users/houndci-bot/events{/privacy}","received_events_url":"https://api.github.com/users/houndci-bot/received_events","type":"User","site_admin":false},"body":"Convert if nested inside else to elsif.","created_at":"2016-10-13T14:00:28Z","updated_at":"2016-10-13T14:00:28Z","html_url":"https://github.com/plauring/review-site-8/pull/8#discussion_r83222418","pull_request_url":"https://api.github.com/repos/plauring/review-site-8/pulls/8","_links":{"self":{"href":"https://api.github.com/repos/plauring/review-site-8/pulls/comments/83222418"},"html":{"href":"https://github.com/plauring/review-site-8/pull/8#discussion_r83222418"},"pull_request":{"href":"https://api.github.com/repos/plauring/review-site-8/pulls/8"}}},"pull_request":{"url":"https://api.github.com/repos/plauring/review-site-8/pulls/8","id":89207025,"html_url":"https://github.com/plauring/review-site-8/pull/8","diff_url":"https://github.com/plauring/review-site-8/pull/8.diff","patch_url":"https://github.com/plauring/review-site-8/pull/8.patch","issue_url":"https://api.github.com/repos/plauring/review-site-8/issues/8","number":8,"state":"open","locked":false,"title":"Votes on reviews","user":{"login":"plauring","id":21070291,"avatar_url":"https://avatars.githubusercontent.com/u/21070291?v=3","gravatar_id":"","url":"https://api.github.com/users/plauring","html_url":"https://github.com/plauring","followers_url":"https://api.github.com/users/plauring/followers","following_url":"https://api.github.com/users/plauring/following{/other_user}","gists_url":"https://api.github.com/users/plauring/gists{/gist_id}","starred_url":"https://api.github.com/users/plauring/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plauring/subscriptions","organizations_url":"https://api.github.com/users/plauring/orgs","repos_url":"https://api.github.com/users/plauring/repos","events_url":"https://api.github.com/users/plauring/events{/privacy}","received_events_url":"https://api.github.com/users/plauring/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-10-13T13:55:33Z","updated_at":"2016-10-13T14:00:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"70ecfe4d5711426d1268822c42740bbf8ea7195a","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/plauring/review-site-8/pulls/8/commits","review_comments_url":"https://api.github.com/repos/plauring/review-site-8/pulls/8/comments","review_comment_url":"https://api.github.com/repos/plauring/review-site-8/pulls/comments{/number}","comments_url":"https://api.github.com/repos/plauring/review-site-8/issues/8/comments","statuses_url":"https://api.github.com/repos/plauring/review-site-8/statuses/0b01fefeffb6dc24ef701bbb2ef16d35ca4d0ac6","head":{"label":"plauring:votes_on_reviews","ref":"votes_on_reviews","sha":"0b01fefeffb6dc24ef701bbb2ef16d35ca4d0ac6","user":{"login":"plauring","id":21070291,"avatar_url":"https://avatars.githubusercontent.com/u/21070291?v=3","gravatar_id":"","url":"https://api.github.com/users/plauring","html_url":"https://github.com/plauring","followers_url":"https://api.github.com/users/plauring/followers","following_url":"https://api.github.com/users/plauring/following{/other_user}","gists_url":"https://api.github.com/users/plauring/gists{/gist_id}","starred_url":"https://api.github.com/users/plauring/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plauring/subscriptions","organizations_url":"https://api.github.com/users/plauring/orgs","repos_url":"https://api.github.com/users/plauring/repos","events_url":"https://api.github.com/users/plauring/events{/privacy}","received_events_url":"https://api.github.com/users/plauring/received_events","type":"User","site_admin":false},"repo":{"id":69880277,"name":"review-site-8","full_name":"plauring/review-site-8","owner":{"login":"plauring","id":21070291,"avatar_url":"https://avatars.githubusercontent.com/u/21070291?v=3","gravatar_id":"","url":"https://api.github.com/users/plauring","html_url":"https://github.com/plauring","followers_url":"https://api.github.com/users/plauring/followers","following_url":"https://api.github.com/users/plauring/following{/other_user}","gists_url":"https://api.github.com/users/plauring/gists{/gist_id}","starred_url":"https://api.github.com/users/plauring/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plauring/subscriptions","organizations_url":"https://api.github.com/users/plauring/orgs","repos_url":"https://api.github.com/users/plauring/repos","events_url":"https://api.github.com/users/plauring/events{/privacy}","received_events_url":"https://api.github.com/users/plauring/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/plauring/review-site-8","description":null,"fork":false,"url":"https://api.github.com/repos/plauring/review-site-8","forks_url":"https://api.github.com/repos/plauring/review-site-8/forks","keys_url":"https://api.github.com/repos/plauring/review-site-8/keys{/key_id}","collaborators_url":"https://api.github.com/repos/plauring/review-site-8/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/plauring/review-site-8/teams","hooks_url":"https://api.github.com/repos/plauring/review-site-8/hooks","issue_events_url":"https://api.github.com/repos/plauring/review-site-8/issues/events{/number}","events_url":"https://api.github.com/repos/plauring/review-site-8/events","assignees_url":"https://api.github.com/repos/plauring/review-site-8/assignees{/user}","branches_url":"https://api.github.com/repos/plauring/review-site-8/branches{/branch}","tags_url":"https://api.github.com/repos/plauring/review-site-8/tags","blobs_url":"https://api.github.com/repos/plauring/review-site-8/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/plauring/review-site-8/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/plauring/review-site-8/git/refs{/sha}","trees_url":"https://api.github.com/repos/plauring/review-site-8/git/trees{/sha}","statuses_url":"https://api.github.com/repos/plauring/review-site-8/statuses/{sha}","languages_url":"https://api.github.com/repos/plauring/review-site-8/languages","stargazers_url":"https://api.github.com/repos/plauring/review-site-8/stargazers","contributors_url":"https://api.github.com/repos/plauring/review-site-8/contributors","subscribers_url":"https://api.github.com/repos/plauring/review-site-8/subscribers","subscription_url":"https://api.github.com/repos/plauring/review-site-8/subscription","commits_url":"https://api.github.com/repos/plauring/review-site-8/commits{/sha}","git_commits_url":"https://api.github.com/repos/plauring/review-site-8/git/commits{/sha}","comments_url":"https://api.github.com/repos/plauring/review-site-8/comments{/number}","issue_comment_url":"https://api.github.com/repos/plauring/review-site-8/issues/comments{/number}","contents_url":"https://api.github.com/repos/plauring/review-site-8/contents/{+path}","compare_url":"https://api.github.com/repos/plauring/review-site-8/compare/{base}...{head}","merges_url":"https://api.github.com/repos/plauring/review-site-8/merges","archive_url":"https://api.github.com/repos/plauring/review-site-8/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/plauring/review-site-8/downloads","issues_url":"https://api.github.com/repos/plauring/review-site-8/issues{/number}","pulls_url":"https://api.github.com/repos/plauring/review-site-8/pulls{/number}","milestones_url":"https://api.github.com/repos/plauring/review-site-8/milestones{/number}","notifications_url":"https://api.github.com/repos/plauring/review-site-8/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/plauring/review-site-8/labels{/name}","releases_url":"https://api.github.com/repos/plauring/review-site-8/releases{/id}","deployments_url":"https://api.github.com/repos/plauring/review-site-8/deployments","created_at":"2016-10-03T14:45:19Z","updated_at":"2016-10-03T17:49:21Z","pushed_at":"2016-10-13T14:00:11Z","git_url":"git://github.com/plauring/review-site-8.git","ssh_url":"git@github.com:plauring/review-site-8.git","clone_url":"https://github.com/plauring/review-site-8.git","svn_url":"https://github.com/plauring/review-site-8","homepage":null,"size":189,"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":2,"forks":0,"open_issues":2,"watchers":1,"default_branch":"master"}},"base":{"label":"plauring:master","ref":"master","sha":"cb1a9ede72bf91ba5ca6692078f22ab56b023694","user":{"login":"plauring","id":21070291,"avatar_url":"https://avatars.githubusercontent.com/u/21070291?v=3","gravatar_id":"","url":"https://api.github.com/users/plauring","html_url":"https://github.com/plauring","followers_url":"https://api.github.com/users/plauring/followers","following_url":"https://api.github.com/users/plauring/following{/other_user}","gists_url":"https://api.github.com/users/plauring/gists{/gist_id}","starred_url":"https://api.github.com/users/plauring/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plauring/subscriptions","organizations_url":"https://api.github.com/users/plauring/orgs","repos_url":"https://api.github.com/users/plauring/repos","events_url":"https://api.github.com/users/plauring/events{/privacy}","received_events_url":"https://api.github.com/users/plauring/received_events","type":"User","site_admin":false},"repo":{"id":69880277,"name":"review-site-8","full_name":"plauring/review-site-8","owner":{"login":"plauring","id":21070291,"avatar_url":"https://avatars.githubusercontent.com/u/21070291?v=3","gravatar_id":"","url":"https://api.github.com/users/plauring","html_url":"https://github.com/plauring","followers_url":"https://api.github.com/users/plauring/followers","following_url":"https://api.github.com/users/plauring/following{/other_user}","gists_url":"https://api.github.com/users/plauring/gists{/gist_id}","starred_url":"https://api.github.com/users/plauring/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plauring/subscriptions","organizations_url":"https://api.github.com/users/plauring/orgs","repos_url":"https://api.github.com/users/plauring/repos","events_url":"https://api.github.com/users/plauring/events{/privacy}","received_events_url":"https://api.github.com/users/plauring/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/plauring/review-site-8","description":null,"fork":false,"url":"https://api.github.com/repos/plauring/review-site-8","forks_url":"https://api.github.com/repos/plauring/review-site-8/forks","keys_url":"https://api.github.com/repos/plauring/review-site-8/keys{/key_id}","collaborators_url":"https://api.github.com/repos/plauring/review-site-8/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/plauring/review-site-8/teams","hooks_url":"https://api.github.com/repos/plauring/review-site-8/hooks","issue_events_url":"https://api.github.com/repos/plauring/review-site-8/issues/events{/number}","events_url":"https://api.github.com/repos/plauring/review-site-8/events","assignees_url":"https://api.github.com/repos/plauring/review-site-8/assignees{/user}","branches_url":"https://api.github.com/repos/plauring/review-site-8/branches{/branch}","tags_url":"https://api.github.com/repos/plauring/review-site-8/tags","blobs_url":"https://api.github.com/repos/plauring/review-site-8/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/plauring/review-site-8/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/plauring/review-site-8/git/refs{/sha}","trees_url":"https://api.github.com/repos/plauring/review-site-8/git/trees{/sha}","statuses_url":"https://api.github.com/repos/plauring/review-site-8/statuses/{sha}","languages_url":"https://api.github.com/repos/plauring/review-site-8/languages","stargazers_url":"https://api.github.com/repos/plauring/review-site-8/stargazers","contributors_url":"https://api.github.com/repos/plauring/review-site-8/contributors","subscribers_url":"https://api.github.com/repos/plauring/review-site-8/subscribers","subscription_url":"https://api.github.com/repos/plauring/review-site-8/subscription","commits_url":"https://api.github.com/repos/plauring/review-site-8/commits{/sha}","git_commits_url":"https://api.github.com/repos/plauring/review-site-8/git/commits{/sha}","comments_url":"https://api.github.com/repos/plauring/review-site-8/comments{/number}","issue_comment_url":"https://api.github.com/repos/plauring/review-site-8/issues/comments{/number}","contents_url":"https://api.github.com/repos/plauring/review-site-8/contents/{+path}","compare_url":"https://api.github.com/repos/plauring/review-site-8/compare/{base}...{head}","merges_url":"https://api.github.com/repos/plauring/review-site-8/merges","archive_url":"https://api.github.com/repos/plauring/review-site-8/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/plauring/review-site-8/downloads","issues_url":"https://api.github.com/repos/plauring/review-site-8/issues{/number}","pulls_url":"https://api.github.com/repos/plauring/review-site-8/pulls{/number}","milestones_url":"https://api.github.com/repos/plauring/review-site-8/milestones{/number}","notifications_url":"https://api.github.com/repos/plauring/review-site-8/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/plauring/review-site-8/labels{/name}","releases_url":"https://api.github.com/repos/plauring/review-site-8/releases{/id}","deployments_url":"https://api.github.com/repos/plauring/review-site-8/deployments","created_at":"2016-10-03T14:45:19Z","updated_at":"2016-10-03T17:49:21Z","pushed_at":"2016-10-13T14:00:11Z","git_url":"git://github.com/plauring/review-site-8.git","ssh_url":"git@github.com:plauring/review-site-8.git","clone_url":"https://github.com/plauring/review-site-8.git","svn_url":"https://github.com/plauring/review-site-8","homepage":null,"size":189,"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":2,"forks":0,"open_issues":2,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/plauring/review-site-8/pulls/8"},"html":{"href":"https://github.com/plauring/review-site-8/pull/8"},"issue":{"href":"https://api.github.com/repos/plauring/review-site-8/issues/8"},"comments":{"href":"https://api.github.com/repos/plauring/review-site-8/issues/8/comments"},"review_comments":{"href":"https://api.github.com/repos/plauring/review-site-8/pulls/8/comments"},"review_comment":{"href":"https://api.github.com/repos/plauring/review-site-8/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/plauring/review-site-8/pulls/8/commits"},"statuses":{"href":"https://api.github.com/repos/plauring/review-site-8/statuses/0b01fefeffb6dc24ef701bbb2ef16d35ca4d0ac6"}}}}
{"actor":{"display_login":"houndci-bot"}}