GitHub PullRequestReviewCommentEvent at 2014-07-09 18:33:12
Repository: app_radio
Actor: mumoc
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/Zauvohi/app_radio/pulls/comments/14727113","id":14727113,"diff_hunk":"@@ -0,0 +1,50 @@\n+class MessagesSearchController < ApplicationController\n+  before_action :search, only: [:index]\n+\n+  def new\n+    render :search_form\n+  end\n+\n+  def search\n+    @messages = search_params.inject(Message.new) do |scope, (field, value)|\n+                  case field.to_sym\n+                  when :number\n+                    scope = search_by_number(value)\n+                  when :precedence\n+                    scope = Message.where(value)\n+                  when :station_of_origin\n+                    scope = search_by_station(value)\n+                  else\n+                    scope\n+                  end\n+                end\n+  end\n+\n+  def index\n+    if (@messages.count == 1) && (@messages.first.number == search_params[:number])","path":"app/controllers/messages_search_controller.rb","position":24,"original_position":24,"commit_id":"da698771f89c8da94d14831d579001695585a86f","original_commit_id":"da698771f89c8da94d14831d579001695585a86f","user":{"login":"mumoc","id":399229,"avatar_url":"https://avatars.githubusercontent.com/u/399229?","gravatar_id":"8b6249aa737ae16cc17d7ba1db528407","url":"https://api.github.com/users/mumoc","html_url":"https://github.com/mumoc","followers_url":"https://api.github.com/users/mumoc/followers","following_url":"https://api.github.com/users/mumoc/following{/other_user}","gists_url":"https://api.github.com/users/mumoc/gists{/gist_id}","starred_url":"https://api.github.com/users/mumoc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mumoc/subscriptions","organizations_url":"https://api.github.com/users/mumoc/orgs","repos_url":"https://api.github.com/users/mumoc/repos","events_url":"https://api.github.com/users/mumoc/events{/privacy}","received_events_url":"https://api.github.com/users/mumoc/received_events","type":"User","site_admin":false},"body":"I would move this logic to a before_action, something like \r\n```\r\nbefore_action :find_message, only: :index\r\n\r\ndef index\r\n  if @message\r\n     redirect_to @message\r\n  else\r\n    render :search_form\r\n   end\r\nend\r\n\r\nprivate\r\ndef find_message\r\n  @message = @messages.first if (@messages.any? && (@messages.first.number == search_params[:number]))\r\nend\r\n```\r\nthe list method isn't needed, and you're moving the logic to a more descriptive method ....","created_at":"2014-07-09T18:33:12Z","updated_at":"2014-07-09T18:33:12Z","html_url":"https://github.com/Zauvohi/app_radio/pull/9#discussion_r14727113","pull_request_url":"https://api.github.com/repos/Zauvohi/app_radio/pulls/9","_links":{"self":{"href":"https://api.github.com/repos/Zauvohi/app_radio/pulls/comments/14727113"},"html":{"href":"https://github.com/Zauvohi/app_radio/pull/9#discussion_r14727113"},"pull_request":{"href":"https://api.github.com/repos/Zauvohi/app_radio/pulls/9"}}},"pull_request":{"url":"https://api.github.com/repos/Zauvohi/app_radio/pulls/9","id":18177028,"html_url":"https://github.com/Zauvohi/app_radio/pull/9","diff_url":"https://github.com/Zauvohi/app_radio/pull/9.diff","patch_url":"https://github.com/Zauvohi/app_radio/pull/9.patch","issue_url":"https://api.github.com/repos/Zauvohi/app_radio/issues/9","number":9,"state":"open","title":"New controller to handle the searches and clean up of the messages controller","user":{"login":"Zauvohi","id":6665036,"avatar_url":"https://avatars.githubusercontent.com/u/6665036?","gravatar_id":"4d350bb1c8b378670f70e9b49d6bc8c0","url":"https://api.github.com/users/Zauvohi","html_url":"https://github.com/Zauvohi","followers_url":"https://api.github.com/users/Zauvohi/followers","following_url":"https://api.github.com/users/Zauvohi/following{/other_user}","gists_url":"https://api.github.com/users/Zauvohi/gists{/gist_id}","starred_url":"https://api.github.com/users/Zauvohi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zauvohi/subscriptions","organizations_url":"https://api.github.com/users/Zauvohi/orgs","repos_url":"https://api.github.com/users/Zauvohi/repos","events_url":"https://api.github.com/users/Zauvohi/events{/privacy}","received_events_url":"https://api.github.com/users/Zauvohi/received_events","type":"User","site_admin":false},"body":"I made a controller to handle the searches so the MessagesController doesn't have to take care of them, also cleaned up the Model since the filtering and most of the search was done on the model.\r\n\r\nAlso I added the new routes, moved the views used by the search controller and edited them a little bit.","created_at":"2014-07-09T18:19:26Z","updated_at":"2014-07-09T18:33:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3d3ec58c70215a4f5b42e64615770df78cbb9d08","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Zauvohi/app_radio/pulls/9/commits","review_comments_url":"https://api.github.com/repos/Zauvohi/app_radio/pulls/9/comments","review_comment_url":"https://api.github.com/repos/Zauvohi/app_radio/pulls/comments/{number}","comments_url":"https://api.github.com/repos/Zauvohi/app_radio/issues/9/comments","statuses_url":"https://api.github.com/repos/Zauvohi/app_radio/statuses/da698771f89c8da94d14831d579001695585a86f","head":{"label":"Zauvohi:development","ref":"development","sha":"da698771f89c8da94d14831d579001695585a86f","user":{"login":"Zauvohi","id":6665036,"avatar_url":"https://avatars.githubusercontent.com/u/6665036?","gravatar_id":"4d350bb1c8b378670f70e9b49d6bc8c0","url":"https://api.github.com/users/Zauvohi","html_url":"https://github.com/Zauvohi","followers_url":"https://api.github.com/users/Zauvohi/followers","following_url":"https://api.github.com/users/Zauvohi/following{/other_user}","gists_url":"https://api.github.com/users/Zauvohi/gists{/gist_id}","starred_url":"https://api.github.com/users/Zauvohi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zauvohi/subscriptions","organizations_url":"https://api.github.com/users/Zauvohi/orgs","repos_url":"https://api.github.com/users/Zauvohi/repos","events_url":"https://api.github.com/users/Zauvohi/events{/privacy}","received_events_url":"https://api.github.com/users/Zauvohi/received_events","type":"User","site_admin":false},"repo":{"id":19706977,"name":"app_radio","full_name":"Zauvohi/app_radio","owner":{"login":"Zauvohi","id":6665036,"avatar_url":"https://avatars.githubusercontent.com/u/6665036?","gravatar_id":"4d350bb1c8b378670f70e9b49d6bc8c0","url":"https://api.github.com/users/Zauvohi","html_url":"https://github.com/Zauvohi","followers_url":"https://api.github.com/users/Zauvohi/followers","following_url":"https://api.github.com/users/Zauvohi/following{/other_user}","gists_url":"https://api.github.com/users/Zauvohi/gists{/gist_id}","starred_url":"https://api.github.com/users/Zauvohi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zauvohi/subscriptions","organizations_url":"https://api.github.com/users/Zauvohi/orgs","repos_url":"https://api.github.com/users/Zauvohi/repos","events_url":"https://api.github.com/users/Zauvohi/events{/privacy}","received_events_url":"https://api.github.com/users/Zauvohi/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Zauvohi/app_radio","description":"A rails application to manage emergency messages between radio operators with offline support and will use OCRA to make a stand-alone app for Windows users.","fork":false,"url":"https://api.github.com/repos/Zauvohi/app_radio","forks_url":"https://api.github.com/repos/Zauvohi/app_radio/forks","keys_url":"https://api.github.com/repos/Zauvohi/app_radio/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Zauvohi/app_radio/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Zauvohi/app_radio/teams","hooks_url":"https://api.github.com/repos/Zauvohi/app_radio/hooks","issue_events_url":"https://api.github.com/repos/Zauvohi/app_radio/issues/events{/number}","events_url":"https://api.github.com/repos/Zauvohi/app_radio/events","assignees_url":"https://api.github.com/repos/Zauvohi/app_radio/assignees{/user}","branches_url":"https://api.github.com/repos/Zauvohi/app_radio/branches{/branch}","tags_url":"https://api.github.com/repos/Zauvohi/app_radio/tags","blobs_url":"https://api.github.com/repos/Zauvohi/app_radio/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Zauvohi/app_radio/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Zauvohi/app_radio/git/refs{/sha}","trees_url":"https://api.github.com/repos/Zauvohi/app_radio/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Zauvohi/app_radio/statuses/{sha}","languages_url":"https://api.github.com/repos/Zauvohi/app_radio/languages","stargazers_url":"https://api.github.com/repos/Zauvohi/app_radio/stargazers","contributors_url":"https://api.github.com/repos/Zauvohi/app_radio/contributors","subscribers_url":"https://api.github.com/repos/Zauvohi/app_radio/subscribers","subscription_url":"https://api.github.com/repos/Zauvohi/app_radio/subscription","commits_url":"https://api.github.com/repos/Zauvohi/app_radio/commits{/sha}","git_commits_url":"https://api.github.com/repos/Zauvohi/app_radio/git/commits{/sha}","comments_url":"https://api.github.com/repos/Zauvohi/app_radio/comments{/number}","issue_comment_url":"https://api.github.com/repos/Zauvohi/app_radio/issues/comments/{number}","contents_url":"https://api.github.com/repos/Zauvohi/app_radio/contents/{+path}","compare_url":"https://api.github.com/repos/Zauvohi/app_radio/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Zauvohi/app_radio/merges","archive_url":"https://api.github.com/repos/Zauvohi/app_radio/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Zauvohi/app_radio/downloads","issues_url":"https://api.github.com/repos/Zauvohi/app_radio/issues{/number}","pulls_url":"https://api.github.com/repos/Zauvohi/app_radio/pulls{/number}","milestones_url":"https://api.github.com/repos/Zauvohi/app_radio/milestones{/number}","notifications_url":"https://api.github.com/repos/Zauvohi/app_radio/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Zauvohi/app_radio/labels{/name}","releases_url":"https://api.github.com/repos/Zauvohi/app_radio/releases{/id}","created_at":"2014-05-12T16:47:50Z","updated_at":"2014-07-03T18:01:35Z","pushed_at":"2014-07-09T18:15:45Z","git_url":"git://github.com/Zauvohi/app_radio.git","ssh_url":"git@github.com:Zauvohi/app_radio.git","clone_url":"https://github.com/Zauvohi/app_radio.git","svn_url":"https://github.com/Zauvohi/app_radio","homepage":null,"size":143872,"stargazers_count":0,"watchers_count":0,"language":"CSS","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"Zauvohi:windows-stable","ref":"windows-stable","sha":"163a5239945f10b97360247b545cd70438f7b9bd","user":{"login":"Zauvohi","id":6665036,"avatar_url":"https://avatars.githubusercontent.com/u/6665036?","gravatar_id":"4d350bb1c8b378670f70e9b49d6bc8c0","url":"https://api.github.com/users/Zauvohi","html_url":"https://github.com/Zauvohi","followers_url":"https://api.github.com/users/Zauvohi/followers","following_url":"https://api.github.com/users/Zauvohi/following{/other_user}","gists_url":"https://api.github.com/users/Zauvohi/gists{/gist_id}","starred_url":"https://api.github.com/users/Zauvohi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zauvohi/subscriptions","organizations_url":"https://api.github.com/users/Zauvohi/orgs","repos_url":"https://api.github.com/users/Zauvohi/repos","events_url":"https://api.github.com/users/Zauvohi/events{/privacy}","received_events_url":"https://api.github.com/users/Zauvohi/received_events","type":"User","site_admin":false},"repo":{"id":19706977,"name":"app_radio","full_name":"Zauvohi/app_radio","owner":{"login":"Zauvohi","id":6665036,"avatar_url":"https://avatars.githubusercontent.com/u/6665036?","gravatar_id":"4d350bb1c8b378670f70e9b49d6bc8c0","url":"https://api.github.com/users/Zauvohi","html_url":"https://github.com/Zauvohi","followers_url":"https://api.github.com/users/Zauvohi/followers","following_url":"https://api.github.com/users/Zauvohi/following{/other_user}","gists_url":"https://api.github.com/users/Zauvohi/gists{/gist_id}","starred_url":"https://api.github.com/users/Zauvohi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zauvohi/subscriptions","organizations_url":"https://api.github.com/users/Zauvohi/orgs","repos_url":"https://api.github.com/users/Zauvohi/repos","events_url":"https://api.github.com/users/Zauvohi/events{/privacy}","received_events_url":"https://api.github.com/users/Zauvohi/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Zauvohi/app_radio","description":"A rails application to manage emergency messages between radio operators with offline support and will use OCRA to make a stand-alone app for Windows users.","fork":false,"url":"https://api.github.com/repos/Zauvohi/app_radio","forks_url":"https://api.github.com/repos/Zauvohi/app_radio/forks","keys_url":"https://api.github.com/repos/Zauvohi/app_radio/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Zauvohi/app_radio/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Zauvohi/app_radio/teams","hooks_url":"https://api.github.com/repos/Zauvohi/app_radio/hooks","issue_events_url":"https://api.github.com/repos/Zauvohi/app_radio/issues/events{/number}","events_url":"https://api.github.com/repos/Zauvohi/app_radio/events","assignees_url":"https://api.github.com/repos/Zauvohi/app_radio/assignees{/user}","branches_url":"https://api.github.com/repos/Zauvohi/app_radio/branches{/branch}","tags_url":"https://api.github.com/repos/Zauvohi/app_radio/tags","blobs_url":"https://api.github.com/repos/Zauvohi/app_radio/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Zauvohi/app_radio/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Zauvohi/app_radio/git/refs{/sha}","trees_url":"https://api.github.com/repos/Zauvohi/app_radio/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Zauvohi/app_radio/statuses/{sha}","languages_url":"https://api.github.com/repos/Zauvohi/app_radio/languages","stargazers_url":"https://api.github.com/repos/Zauvohi/app_radio/stargazers","contributors_url":"https://api.github.com/repos/Zauvohi/app_radio/contributors","subscribers_url":"https://api.github.com/repos/Zauvohi/app_radio/subscribers","subscription_url":"https://api.github.com/repos/Zauvohi/app_radio/subscription","commits_url":"https://api.github.com/repos/Zauvohi/app_radio/commits{/sha}","git_commits_url":"https://api.github.com/repos/Zauvohi/app_radio/git/commits{/sha}","comments_url":"https://api.github.com/repos/Zauvohi/app_radio/comments{/number}","issue_comment_url":"https://api.github.com/repos/Zauvohi/app_radio/issues/comments/{number}","contents_url":"https://api.github.com/repos/Zauvohi/app_radio/contents/{+path}","compare_url":"https://api.github.com/repos/Zauvohi/app_radio/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Zauvohi/app_radio/merges","archive_url":"https://api.github.com/repos/Zauvohi/app_radio/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Zauvohi/app_radio/downloads","issues_url":"https://api.github.com/repos/Zauvohi/app_radio/issues{/number}","pulls_url":"https://api.github.com/repos/Zauvohi/app_radio/pulls{/number}","milestones_url":"https://api.github.com/repos/Zauvohi/app_radio/milestones{/number}","notifications_url":"https://api.github.com/repos/Zauvohi/app_radio/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Zauvohi/app_radio/labels{/name}","releases_url":"https://api.github.com/repos/Zauvohi/app_radio/releases{/id}","created_at":"2014-05-12T16:47:50Z","updated_at":"2014-07-03T18:01:35Z","pushed_at":"2014-07-09T18:15:45Z","git_url":"git://github.com/Zauvohi/app_radio.git","ssh_url":"git@github.com:Zauvohi/app_radio.git","clone_url":"https://github.com/Zauvohi/app_radio.git","svn_url":"https://github.com/Zauvohi/app_radio","homepage":null,"size":143872,"stargazers_count":0,"watchers_count":0,"language":"CSS","has_issues":true,"has_downloads":true,"has_wiki":true,"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/Zauvohi/app_radio/pulls/9"},"html":{"href":"https://github.com/Zauvohi/app_radio/pull/9"},"issue":{"href":"https://api.github.com/repos/Zauvohi/app_radio/issues/9"},"comments":{"href":"https://api.github.com/repos/Zauvohi/app_radio/issues/9/comments"},"review_comments":{"href":"https://api.github.com/repos/Zauvohi/app_radio/pulls/9/comments"},"review_comment":{"href":"https://api.github.com/repos/Zauvohi/app_radio/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/Zauvohi/app_radio/pulls/9/commits"},"statuses":{"href":"https://api.github.com/repos/Zauvohi/app_radio/statuses/da698771f89c8da94d14831d579001695585a86f"}}}}