{"action":"created","comment":{"url":"https://api.github.com/repos/jiexu10/pinpoint/pulls/comments/50346576","id":50346576,"diff_hunk":"@@ -0,0 +1,80 @@\n+class MakeRestaurantDetail\n+  attr_reader :venue, :rd\n+\n+  def initialize(rest, query = {})\n+    locu_data = LocuData.new(query)\n+    locu_data.search_function\n+    raw_data_body = locu_data.data.body\n+    @data = JSON.parse(raw_data_body)\n+    if @data['venues'].count == 1\n+      @venue = @data['venues'][0]\n+    else\n+      raise MultipleVenueError\n+    end\n+    @rd = Restaurantdetail.new\n+    @rd.restaurant = rest\n+    make_detail\n+  end\n+\n+  def make_detail\n+    rd.name = venue['name']\n+    rd.description = venue['description']\n+    rd.locuid = venue['locu_id']\n+    rd.phone = venue['contact']['phone']\n+    rd.website_url = venue['website_url']\n+    rd.address_one = venue['location']['address1']\n+    rd.address_two = venue['location']['address2']\n+    rd.city = venue['location']['locality']\n+    rd.state = venue['location']['region']\n+    rd.zip_code = venue['location']['postal_code']\n+    rd.coordinates = venue['location']['geo']['coordinates'].to_s\n+    if venue['delivery']\n+      rd.delivery = venue['delivery']['will deliver'].to_s\n+    end\n+    if rd.save\n+      make_categories(rd) if venue['categories']\n+      make_opentimes(rd) if venue['open_hours']\n+      make_menu(rd) if venue['menus']\n+    else\n+    end\n+  end\n+\n+  def make_categories(rd)\n+    venue['categories'].each do |category|\n+      cat = Category.find_or_create_by(str_id: category['str_id']) do |new_cat|\n+        new_cat.name = category['name']\n+      end\n+      Restaurantcategory.find_or_create_by(restaurantdetail: rd, category: cat)\n+    end\n+  end\n+\n+  def make_opentimes(rd)\n+    venue['open_hours'].each do |key, value|\n+      Opentime.find_or_create_by(day: key) do |new_time|\n+        new_time.restaurantdetail = rd\n+        new_time.open_hour = value[0].first\n+        new_time.close_hour = value[0].last\n+      end\n+    end\n+  end\n+\n+  def make_menu(rd)\n+    venue['menus'].first['sections'].each do |subsec|\n+      subsec['subsections'].each do |subsection|\n+        ms = nil","path":"app/models/make_restaurant_detail.rb","position":64,"original_position":64,"commit_id":"132457b61c8a149ad11438eade1957302149dc69","original_commit_id":"132457b61c8a149ad11438eade1957302149dc69","user":{"login":"houndci","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci","html_url":"https://github.com/houndci","followers_url":"https://api.github.com/users/houndci/followers","following_url":"https://api.github.com/users/houndci/following{/other_user}","gists_url":"https://api.github.com/users/houndci/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci/subscriptions","organizations_url":"https://api.github.com/users/houndci/orgs","repos_url":"https://api.github.com/users/houndci/repos","events_url":"https://api.github.com/users/houndci/events{/privacy}","received_events_url":"https://api.github.com/users/houndci/received_events","type":"User","site_admin":false},"body":"Useless assignment to variable - `ms`.","created_at":"2016-01-21T01:02:21Z","updated_at":"2016-01-21T01:02:21Z","html_url":"https://github.com/jiexu10/pinpoint/pull/32#discussion_r50346576","pull_request_url":"https://api.github.com/repos/jiexu10/pinpoint/pulls/32","_links":{"self":{"href":"https://api.github.com/repos/jiexu10/pinpoint/pulls/comments/50346576"},"html":{"href":"https://github.com/jiexu10/pinpoint/pull/32#discussion_r50346576"},"pull_request":{"href":"https://api.github.com/repos/jiexu10/pinpoint/pulls/32"}}},"pull_request":{"url":"https://api.github.com/repos/jiexu10/pinpoint/pulls/32","id":56691568,"html_url":"https://github.com/jiexu10/pinpoint/pull/32","diff_url":"https://github.com/jiexu10/pinpoint/pull/32.diff","patch_url":"https://github.com/jiexu10/pinpoint/pull/32.patch","issue_url":"https://api.github.com/repos/jiexu10/pinpoint/issues/32","number":32,"state":"open","locked":false,"title":"[Resolves #31] add restaurant details table and associated tables","user":{"login":"jiexu10","id":12928368,"avatar_url":"https://avatars.githubusercontent.com/u/12928368?v=3","gravatar_id":"","url":"https://api.github.com/users/jiexu10","html_url":"https://github.com/jiexu10","followers_url":"https://api.github.com/users/jiexu10/followers","following_url":"https://api.github.com/users/jiexu10/following{/other_user}","gists_url":"https://api.github.com/users/jiexu10/gists{/gist_id}","starred_url":"https://api.github.com/users/jiexu10/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jiexu10/subscriptions","organizations_url":"https://api.github.com/users/jiexu10/orgs","repos_url":"https://api.github.com/users/jiexu10/repos","events_url":"https://api.github.com/users/jiexu10/events{/privacy}","received_events_url":"https://api.github.com/users/jiexu10/received_events","type":"User","site_admin":false},"body":"#29 #31 ","created_at":"2016-01-21T01:02:15Z","updated_at":"2016-01-21T01:02:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2fa75bedd446b8e79d98f5008ddc965c731be630","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/jiexu10/pinpoint/pulls/32/commits","review_comments_url":"https://api.github.com/repos/jiexu10/pinpoint/pulls/32/comments","review_comment_url":"https://api.github.com/repos/jiexu10/pinpoint/pulls/comments{/number}","comments_url":"https://api.github.com/repos/jiexu10/pinpoint/issues/32/comments","statuses_url":"https://api.github.com/repos/jiexu10/pinpoint/statuses/132457b61c8a149ad11438eade1957302149dc69","head":{"label":"jiexu10:jx-31-add-restaurant-details-table","ref":"jx-31-add-restaurant-details-table","sha":"132457b61c8a149ad11438eade1957302149dc69","user":{"login":"jiexu10","id":12928368,"avatar_url":"https://avatars.githubusercontent.com/u/12928368?v=3","gravatar_id":"","url":"https://api.github.com/users/jiexu10","html_url":"https://github.com/jiexu10","followers_url":"https://api.github.com/users/jiexu10/followers","following_url":"https://api.github.com/users/jiexu10/following{/other_user}","gists_url":"https://api.github.com/users/jiexu10/gists{/gist_id}","starred_url":"https://api.github.com/users/jiexu10/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jiexu10/subscriptions","organizations_url":"https://api.github.com/users/jiexu10/orgs","repos_url":"https://api.github.com/users/jiexu10/repos","events_url":"https://api.github.com/users/jiexu10/events{/privacy}","received_events_url":"https://api.github.com/users/jiexu10/received_events","type":"User","site_admin":false},"repo":{"id":49346910,"name":"pinpoint","full_name":"jiexu10/pinpoint","owner":{"login":"jiexu10","id":12928368,"avatar_url":"https://avatars.githubusercontent.com/u/12928368?v=3","gravatar_id":"","url":"https://api.github.com/users/jiexu10","html_url":"https://github.com/jiexu10","followers_url":"https://api.github.com/users/jiexu10/followers","following_url":"https://api.github.com/users/jiexu10/following{/other_user}","gists_url":"https://api.github.com/users/jiexu10/gists{/gist_id}","starred_url":"https://api.github.com/users/jiexu10/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jiexu10/subscriptions","organizations_url":"https://api.github.com/users/jiexu10/orgs","repos_url":"https://api.github.com/users/jiexu10/repos","events_url":"https://api.github.com/users/jiexu10/events{/privacy}","received_events_url":"https://api.github.com/users/jiexu10/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jiexu10/pinpoint","description":"Pinpoint App - Find your Food","fork":false,"url":"https://api.github.com/repos/jiexu10/pinpoint","forks_url":"https://api.github.com/repos/jiexu10/pinpoint/forks","keys_url":"https://api.github.com/repos/jiexu10/pinpoint/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jiexu10/pinpoint/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jiexu10/pinpoint/teams","hooks_url":"https://api.github.com/repos/jiexu10/pinpoint/hooks","issue_events_url":"https://api.github.com/repos/jiexu10/pinpoint/issues/events{/number}","events_url":"https://api.github.com/repos/jiexu10/pinpoint/events","assignees_url":"https://api.github.com/repos/jiexu10/pinpoint/assignees{/user}","branches_url":"https://api.github.com/repos/jiexu10/pinpoint/branches{/branch}","tags_url":"https://api.github.com/repos/jiexu10/pinpoint/tags","blobs_url":"https://api.github.com/repos/jiexu10/pinpoint/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jiexu10/pinpoint/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jiexu10/pinpoint/git/refs{/sha}","trees_url":"https://api.github.com/repos/jiexu10/pinpoint/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jiexu10/pinpoint/statuses/{sha}","languages_url":"https://api.github.com/repos/jiexu10/pinpoint/languages","stargazers_url":"https://api.github.com/repos/jiexu10/pinpoint/stargazers","contributors_url":"https://api.github.com/repos/jiexu10/pinpoint/contributors","subscribers_url":"https://api.github.com/repos/jiexu10/pinpoint/subscribers","subscription_url":"https://api.github.com/repos/jiexu10/pinpoint/subscription","commits_url":"https://api.github.com/repos/jiexu10/pinpoint/commits{/sha}","git_commits_url":"https://api.github.com/repos/jiexu10/pinpoint/git/commits{/sha}","comments_url":"https://api.github.com/repos/jiexu10/pinpoint/comments{/number}","issue_comment_url":"https://api.github.com/repos/jiexu10/pinpoint/issues/comments{/number}","contents_url":"https://api.github.com/repos/jiexu10/pinpoint/contents/{+path}","compare_url":"https://api.github.com/repos/jiexu10/pinpoint/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jiexu10/pinpoint/merges","archive_url":"https://api.github.com/repos/jiexu10/pinpoint/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jiexu10/pinpoint/downloads","issues_url":"https://api.github.com/repos/jiexu10/pinpoint/issues{/number}","pulls_url":"https://api.github.com/repos/jiexu10/pinpoint/pulls{/number}","milestones_url":"https://api.github.com/repos/jiexu10/pinpoint/milestones{/number}","notifications_url":"https://api.github.com/repos/jiexu10/pinpoint/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jiexu10/pinpoint/labels{/name}","releases_url":"https://api.github.com/repos/jiexu10/pinpoint/releases{/id}","created_at":"2016-01-10T00:12:40Z","updated_at":"2016-01-18T23:55:58Z","pushed_at":"2016-01-21T01:02:16Z","git_url":"git://github.com/jiexu10/pinpoint.git","ssh_url":"git@github.com:jiexu10/pinpoint.git","clone_url":"https://github.com/jiexu10/pinpoint.git","svn_url":"https://github.com/jiexu10/pinpoint","homepage":"https://pinpoint-food.herokuapp.com","size":530,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":14,"forks":0,"open_issues":14,"watchers":0,"default_branch":"master"}},"base":{"label":"jiexu10:master","ref":"master","sha":"eb33f6daf609638ee0ec9da0458bd15bfacc6e99","user":{"login":"jiexu10","id":12928368,"avatar_url":"https://avatars.githubusercontent.com/u/12928368?v=3","gravatar_id":"","url":"https://api.github.com/users/jiexu10","html_url":"https://github.com/jiexu10","followers_url":"https://api.github.com/users/jiexu10/followers","following_url":"https://api.github.com/users/jiexu10/following{/other_user}","gists_url":"https://api.github.com/users/jiexu10/gists{/gist_id}","starred_url":"https://api.github.com/users/jiexu10/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jiexu10/subscriptions","organizations_url":"https://api.github.com/users/jiexu10/orgs","repos_url":"https://api.github.com/users/jiexu10/repos","events_url":"https://api.github.com/users/jiexu10/events{/privacy}","received_events_url":"https://api.github.com/users/jiexu10/received_events","type":"User","site_admin":false},"repo":{"id":49346910,"name":"pinpoint","full_name":"jiexu10/pinpoint","owner":{"login":"jiexu10","id":12928368,"avatar_url":"https://avatars.githubusercontent.com/u/12928368?v=3","gravatar_id":"","url":"https://api.github.com/users/jiexu10","html_url":"https://github.com/jiexu10","followers_url":"https://api.github.com/users/jiexu10/followers","following_url":"https://api.github.com/users/jiexu10/following{/other_user}","gists_url":"https://api.github.com/users/jiexu10/gists{/gist_id}","starred_url":"https://api.github.com/users/jiexu10/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jiexu10/subscriptions","organizations_url":"https://api.github.com/users/jiexu10/orgs","repos_url":"https://api.github.com/users/jiexu10/repos","events_url":"https://api.github.com/users/jiexu10/events{/privacy}","received_events_url":"https://api.github.com/users/jiexu10/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jiexu10/pinpoint","description":"Pinpoint App - Find your Food","fork":false,"url":"https://api.github.com/repos/jiexu10/pinpoint","forks_url":"https://api.github.com/repos/jiexu10/pinpoint/forks","keys_url":"https://api.github.com/repos/jiexu10/pinpoint/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jiexu10/pinpoint/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jiexu10/pinpoint/teams","hooks_url":"https://api.github.com/repos/jiexu10/pinpoint/hooks","issue_events_url":"https://api.github.com/repos/jiexu10/pinpoint/issues/events{/number}","events_url":"https://api.github.com/repos/jiexu10/pinpoint/events","assignees_url":"https://api.github.com/repos/jiexu10/pinpoint/assignees{/user}","branches_url":"https://api.github.com/repos/jiexu10/pinpoint/branches{/branch}","tags_url":"https://api.github.com/repos/jiexu10/pinpoint/tags","blobs_url":"https://api.github.com/repos/jiexu10/pinpoint/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jiexu10/pinpoint/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jiexu10/pinpoint/git/refs{/sha}","trees_url":"https://api.github.com/repos/jiexu10/pinpoint/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jiexu10/pinpoint/statuses/{sha}","languages_url":"https://api.github.com/repos/jiexu10/pinpoint/languages","stargazers_url":"https://api.github.com/repos/jiexu10/pinpoint/stargazers","contributors_url":"https://api.github.com/repos/jiexu10/pinpoint/contributors","subscribers_url":"https://api.github.com/repos/jiexu10/pinpoint/subscribers","subscription_url":"https://api.github.com/repos/jiexu10/pinpoint/subscription","commits_url":"https://api.github.com/repos/jiexu10/pinpoint/commits{/sha}","git_commits_url":"https://api.github.com/repos/jiexu10/pinpoint/git/commits{/sha}","comments_url":"https://api.github.com/repos/jiexu10/pinpoint/comments{/number}","issue_comment_url":"https://api.github.com/repos/jiexu10/pinpoint/issues/comments{/number}","contents_url":"https://api.github.com/repos/jiexu10/pinpoint/contents/{+path}","compare_url":"https://api.github.com/repos/jiexu10/pinpoint/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jiexu10/pinpoint/merges","archive_url":"https://api.github.com/repos/jiexu10/pinpoint/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jiexu10/pinpoint/downloads","issues_url":"https://api.github.com/repos/jiexu10/pinpoint/issues{/number}","pulls_url":"https://api.github.com/repos/jiexu10/pinpoint/pulls{/number}","milestones_url":"https://api.github.com/repos/jiexu10/pinpoint/milestones{/number}","notifications_url":"https://api.github.com/repos/jiexu10/pinpoint/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jiexu10/pinpoint/labels{/name}","releases_url":"https://api.github.com/repos/jiexu10/pinpoint/releases{/id}","created_at":"2016-01-10T00:12:40Z","updated_at":"2016-01-18T23:55:58Z","pushed_at":"2016-01-21T01:02:16Z","git_url":"git://github.com/jiexu10/pinpoint.git","ssh_url":"git@github.com:jiexu10/pinpoint.git","clone_url":"https://github.com/jiexu10/pinpoint.git","svn_url":"https://github.com/jiexu10/pinpoint","homepage":"https://pinpoint-food.herokuapp.com","size":530,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":14,"forks":0,"open_issues":14,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/jiexu10/pinpoint/pulls/32"},"html":{"href":"https://github.com/jiexu10/pinpoint/pull/32"},"issue":{"href":"https://api.github.com/repos/jiexu10/pinpoint/issues/32"},"comments":{"href":"https://api.github.com/repos/jiexu10/pinpoint/issues/32/comments"},"review_comments":{"href":"https://api.github.com/repos/jiexu10/pinpoint/pulls/32/comments"},"review_comment":{"href":"https://api.github.com/repos/jiexu10/pinpoint/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/jiexu10/pinpoint/pulls/32/commits"},"statuses":{"href":"https://api.github.com/repos/jiexu10/pinpoint/statuses/132457b61c8a149ad11438eade1957302149dc69"}}}}