{"action":"created","comment":{"url":"https://api.github.com/repos/hbellows/black_thursday/pulls/comments/206937962","pull_request_review_id":142448332,"id":206937962,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwNjkzNzk2Mg==","diff_hunk":"@@ -272,30 +272,62 @@ def most_sold_item_for_merchant(merchant_id)\n         successful_invoices << invoice\n         end\n       end\n-     invoice_items = successful_invoices.map do |invoice|\n-       @se.invoice_items.find_all_by_invoice_id(invoice.id)\n-     end.flatten\n-     quantities_by_item_id = Hash.new(0)\n-     invoice_items.map do |invoice_item|\n+    invoice_items = successful_invoices.map do |invoice|\n+      @se.invoice_items.find_all_by_invoice_id(invoice.id)\n+      end.flatten\n+    quantities_by_item_id = Hash.new(0)\n+    invoice_items.map do |invoice_item|\n       quantities_by_item_id[invoice_item.item_id] += invoice_item.quantity\n     end\n-     max = quantities_by_item_id.max_by do |item_id, quantity|\n-       quantity\n+    max = quantities_by_item_id.max_by do |item_id, quantity|\n+      quantity\n      end\n-     max_quantity = max[1]\n-     ids_and_max_value = quantities_by_item_id.find_all do |id, quantity|\n+    max_quantity = max[1]\n+    ids_and_max_value = quantities_by_item_id.find_all do |id, quantity|\n        quantity == max_quantity\n      end.flatten\n-     ids = ids_and_max_value.map.with_index do |num, index|\n-       if num.to_s.length > 8\n-         ids_and_max_value.delete_at(index)\n-       end\n-     end\n+    ids = ids_and_max_value.map.with_index do |num, index|\n+      if num.to_s.length > 8\n+        ids_and_max_value.delete_at(index)\n+      end\n+    end\n      items = []\n      ids.each do |id|\n       items << @se.items.find_by_id(id)\n      end\n      return items.compact\n-   end\n+  end\n+\n+   def best_item_for_merchant(merchant_id)\n+     grouped = @se.invoices.all.find_all do |invoice|\n+        invoice.merchant_id == merchant_id\n+      end\n+      invoice_items_paid_in_full = []\n+      grouped.each do |invoice|\n+        if invoice_paid_in_full?(invoice.id)\n+          invoice_items_paid_in_full << @se.invoice_items.find_all_by_invoice_id(invoice.id)\n+      end\n+    end.flatten\n+    grouped = invoice_items_paid_in_full.flatten.group_by do |invoice_item|\n+      invoice_item.item_id\n+      end\n+    grouped.map do |item_id, invoice_item|\n+      grouped[item_id] = (invoice_item[0].quantity.to_f * (invoice_item[0].unit_price.to_f.round(2))).round(2)\n+      end\n+    top_value = grouped.max_by do |item_id, invoice_value|","path":"lib/sales_analyst.rb","position":61,"original_position":61,"commit_id":"29f5d6195509f9fc5773338222f912eb1c861ac5","original_commit_id":"29f5d6195509f9fc5773338222f912eb1c861ac5","user":{"login":"houndci-bot","id":6697940,"node_id":"MDQ6VXNlcjY2OTc5NDA=","avatar_url":"https://avatars0.githubusercontent.com/u/6697940?v=4","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":"Layout/IndentationConsistency: Inconsistent indentation detected.<br>Lint/UnusedBlockArgument: Unused block argument - item_id. If it's necessary, use _ or _item_id as an argument name to indicate that it won't be used.","created_at":"2018-08-01T16:02:07Z","updated_at":"2018-08-01T16:02:08Z","html_url":"https://github.com/hbellows/black_thursday/pull/97#discussion_r206937962","pull_request_url":"https://api.github.com/repos/hbellows/black_thursday/pulls/97","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/hbellows/black_thursday/pulls/comments/206937962"},"html":{"href":"https://github.com/hbellows/black_thursday/pull/97#discussion_r206937962"},"pull_request":{"href":"https://api.github.com/repos/hbellows/black_thursday/pulls/97"}}},"pull_request":{"url":"https://api.github.com/repos/hbellows/black_thursday/pulls/97","id":205474741,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA1NDc0NzQx","html_url":"https://github.com/hbellows/black_thursday/pull/97","diff_url":"https://github.com/hbellows/black_thursday/pull/97.diff","patch_url":"https://github.com/hbellows/black_thursday/pull/97.patch","issue_url":"https://api.github.com/repos/hbellows/black_thursday/issues/97","number":97,"state":"open","locked":false,"title":"Sales analyst 21","user":{"login":"patmccartney2","id":30877651,"node_id":"MDQ6VXNlcjMwODc3NjUx","avatar_url":"https://avatars1.githubusercontent.com/u/30877651?v=4","gravatar_id":"","url":"https://api.github.com/users/patmccartney2","html_url":"https://github.com/patmccartney2","followers_url":"https://api.github.com/users/patmccartney2/followers","following_url":"https://api.github.com/users/patmccartney2/following{/other_user}","gists_url":"https://api.github.com/users/patmccartney2/gists{/gist_id}","starred_url":"https://api.github.com/users/patmccartney2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/patmccartney2/subscriptions","organizations_url":"https://api.github.com/users/patmccartney2/orgs","repos_url":"https://api.github.com/users/patmccartney2/repos","events_url":"https://api.github.com/users/patmccartney2/events{/privacy}","received_events_url":"https://api.github.com/users/patmccartney2/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-08-01T16:01:53Z","updated_at":"2018-08-01T16:02:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/hbellows/black_thursday/pulls/97/commits","review_comments_url":"https://api.github.com/repos/hbellows/black_thursday/pulls/97/comments","review_comment_url":"https://api.github.com/repos/hbellows/black_thursday/pulls/comments{/number}","comments_url":"https://api.github.com/repos/hbellows/black_thursday/issues/97/comments","statuses_url":"https://api.github.com/repos/hbellows/black_thursday/statuses/29f5d6195509f9fc5773338222f912eb1c861ac5","head":{"label":"hbellows:sales_analyst_21","ref":"sales_analyst_21","sha":"29f5d6195509f9fc5773338222f912eb1c861ac5","user":{"login":"hbellows","id":35637783,"node_id":"MDQ6VXNlcjM1NjM3Nzgz","avatar_url":"https://avatars2.githubusercontent.com/u/35637783?v=4","gravatar_id":"","url":"https://api.github.com/users/hbellows","html_url":"https://github.com/hbellows","followers_url":"https://api.github.com/users/hbellows/followers","following_url":"https://api.github.com/users/hbellows/following{/other_user}","gists_url":"https://api.github.com/users/hbellows/gists{/gist_id}","starred_url":"https://api.github.com/users/hbellows/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hbellows/subscriptions","organizations_url":"https://api.github.com/users/hbellows/orgs","repos_url":"https://api.github.com/users/hbellows/repos","events_url":"https://api.github.com/users/hbellows/events{/privacy}","received_events_url":"https://api.github.com/users/hbellows/received_events","type":"User","site_admin":false},"repo":{"id":141752686,"node_id":"MDEwOlJlcG9zaXRvcnkxNDE3NTI2ODY=","name":"black_thursday","full_name":"hbellows/black_thursday","owner":{"login":"hbellows","id":35637783,"node_id":"MDQ6VXNlcjM1NjM3Nzgz","avatar_url":"https://avatars2.githubusercontent.com/u/35637783?v=4","gravatar_id":"","url":"https://api.github.com/users/hbellows","html_url":"https://github.com/hbellows","followers_url":"https://api.github.com/users/hbellows/followers","following_url":"https://api.github.com/users/hbellows/following{/other_user}","gists_url":"https://api.github.com/users/hbellows/gists{/gist_id}","starred_url":"https://api.github.com/users/hbellows/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hbellows/subscriptions","organizations_url":"https://api.github.com/users/hbellows/orgs","repos_url":"https://api.github.com/users/hbellows/repos","events_url":"https://api.github.com/users/hbellows/events{/privacy}","received_events_url":"https://api.github.com/users/hbellows/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/hbellows/black_thursday","description":null,"fork":true,"url":"https://api.github.com/repos/hbellows/black_thursday","forks_url":"https://api.github.com/repos/hbellows/black_thursday/forks","keys_url":"https://api.github.com/repos/hbellows/black_thursday/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hbellows/black_thursday/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hbellows/black_thursday/teams","hooks_url":"https://api.github.com/repos/hbellows/black_thursday/hooks","issue_events_url":"https://api.github.com/repos/hbellows/black_thursday/issues/events{/number}","events_url":"https://api.github.com/repos/hbellows/black_thursday/events","assignees_url":"https://api.github.com/repos/hbellows/black_thursday/assignees{/user}","branches_url":"https://api.github.com/repos/hbellows/black_thursday/branches{/branch}","tags_url":"https://api.github.com/repos/hbellows/black_thursday/tags","blobs_url":"https://api.github.com/repos/hbellows/black_thursday/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hbellows/black_thursday/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hbellows/black_thursday/git/refs{/sha}","trees_url":"https://api.github.com/repos/hbellows/black_thursday/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hbellows/black_thursday/statuses/{sha}","languages_url":"https://api.github.com/repos/hbellows/black_thursday/languages","stargazers_url":"https://api.github.com/repos/hbellows/black_thursday/stargazers","contributors_url":"https://api.github.com/repos/hbellows/black_thursday/contributors","subscribers_url":"https://api.github.com/repos/hbellows/black_thursday/subscribers","subscription_url":"https://api.github.com/repos/hbellows/black_thursday/subscription","commits_url":"https://api.github.com/repos/hbellows/black_thursday/commits{/sha}","git_commits_url":"https://api.github.com/repos/hbellows/black_thursday/git/commits{/sha}","comments_url":"https://api.github.com/repos/hbellows/black_thursday/comments{/number}","issue_comment_url":"https://api.github.com/repos/hbellows/black_thursday/issues/comments{/number}","contents_url":"https://api.github.com/repos/hbellows/black_thursday/contents/{+path}","compare_url":"https://api.github.com/repos/hbellows/black_thursday/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hbellows/black_thursday/merges","archive_url":"https://api.github.com/repos/hbellows/black_thursday/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hbellows/black_thursday/downloads","issues_url":"https://api.github.com/repos/hbellows/black_thursday/issues{/number}","pulls_url":"https://api.github.com/repos/hbellows/black_thursday/pulls{/number}","milestones_url":"https://api.github.com/repos/hbellows/black_thursday/milestones{/number}","notifications_url":"https://api.github.com/repos/hbellows/black_thursday/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hbellows/black_thursday/labels{/name}","releases_url":"https://api.github.com/repos/hbellows/black_thursday/releases{/id}","deployments_url":"https://api.github.com/repos/hbellows/black_thursday/deployments","created_at":"2018-07-20T19:59:40Z","updated_at":"2018-08-01T15:57:34Z","pushed_at":"2018-08-01T16:01:53Z","git_url":"git://github.com/hbellows/black_thursday.git","ssh_url":"git@github.com:hbellows/black_thursday.git","clone_url":"https://github.com/hbellows/black_thursday.git","svn_url":"https://github.com/hbellows/black_thursday","homepage":null,"size":1882,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":3,"license":null,"forks":0,"open_issues":3,"watchers":0,"default_branch":"master"}},"base":{"label":"hbellows:master","ref":"master","sha":"48df33816c76d457b6a51778d923fbd9493dbe01","user":{"login":"hbellows","id":35637783,"node_id":"MDQ6VXNlcjM1NjM3Nzgz","avatar_url":"https://avatars2.githubusercontent.com/u/35637783?v=4","gravatar_id":"","url":"https://api.github.com/users/hbellows","html_url":"https://github.com/hbellows","followers_url":"https://api.github.com/users/hbellows/followers","following_url":"https://api.github.com/users/hbellows/following{/other_user}","gists_url":"https://api.github.com/users/hbellows/gists{/gist_id}","starred_url":"https://api.github.com/users/hbellows/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hbellows/subscriptions","organizations_url":"https://api.github.com/users/hbellows/orgs","repos_url":"https://api.github.com/users/hbellows/repos","events_url":"https://api.github.com/users/hbellows/events{/privacy}","received_events_url":"https://api.github.com/users/hbellows/received_events","type":"User","site_admin":false},"repo":{"id":141752686,"node_id":"MDEwOlJlcG9zaXRvcnkxNDE3NTI2ODY=","name":"black_thursday","full_name":"hbellows/black_thursday","owner":{"login":"hbellows","id":35637783,"node_id":"MDQ6VXNlcjM1NjM3Nzgz","avatar_url":"https://avatars2.githubusercontent.com/u/35637783?v=4","gravatar_id":"","url":"https://api.github.com/users/hbellows","html_url":"https://github.com/hbellows","followers_url":"https://api.github.com/users/hbellows/followers","following_url":"https://api.github.com/users/hbellows/following{/other_user}","gists_url":"https://api.github.com/users/hbellows/gists{/gist_id}","starred_url":"https://api.github.com/users/hbellows/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hbellows/subscriptions","organizations_url":"https://api.github.com/users/hbellows/orgs","repos_url":"https://api.github.com/users/hbellows/repos","events_url":"https://api.github.com/users/hbellows/events{/privacy}","received_events_url":"https://api.github.com/users/hbellows/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/hbellows/black_thursday","description":null,"fork":true,"url":"https://api.github.com/repos/hbellows/black_thursday","forks_url":"https://api.github.com/repos/hbellows/black_thursday/forks","keys_url":"https://api.github.com/repos/hbellows/black_thursday/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hbellows/black_thursday/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hbellows/black_thursday/teams","hooks_url":"https://api.github.com/repos/hbellows/black_thursday/hooks","issue_events_url":"https://api.github.com/repos/hbellows/black_thursday/issues/events{/number}","events_url":"https://api.github.com/repos/hbellows/black_thursday/events","assignees_url":"https://api.github.com/repos/hbellows/black_thursday/assignees{/user}","branches_url":"https://api.github.com/repos/hbellows/black_thursday/branches{/branch}","tags_url":"https://api.github.com/repos/hbellows/black_thursday/tags","blobs_url":"https://api.github.com/repos/hbellows/black_thursday/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hbellows/black_thursday/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hbellows/black_thursday/git/refs{/sha}","trees_url":"https://api.github.com/repos/hbellows/black_thursday/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hbellows/black_thursday/statuses/{sha}","languages_url":"https://api.github.com/repos/hbellows/black_thursday/languages","stargazers_url":"https://api.github.com/repos/hbellows/black_thursday/stargazers","contributors_url":"https://api.github.com/repos/hbellows/black_thursday/contributors","subscribers_url":"https://api.github.com/repos/hbellows/black_thursday/subscribers","subscription_url":"https://api.github.com/repos/hbellows/black_thursday/subscription","commits_url":"https://api.github.com/repos/hbellows/black_thursday/commits{/sha}","git_commits_url":"https://api.github.com/repos/hbellows/black_thursday/git/commits{/sha}","comments_url":"https://api.github.com/repos/hbellows/black_thursday/comments{/number}","issue_comment_url":"https://api.github.com/repos/hbellows/black_thursday/issues/comments{/number}","contents_url":"https://api.github.com/repos/hbellows/black_thursday/contents/{+path}","compare_url":"https://api.github.com/repos/hbellows/black_thursday/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hbellows/black_thursday/merges","archive_url":"https://api.github.com/repos/hbellows/black_thursday/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hbellows/black_thursday/downloads","issues_url":"https://api.github.com/repos/hbellows/black_thursday/issues{/number}","pulls_url":"https://api.github.com/repos/hbellows/black_thursday/pulls{/number}","milestones_url":"https://api.github.com/repos/hbellows/black_thursday/milestones{/number}","notifications_url":"https://api.github.com/repos/hbellows/black_thursday/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hbellows/black_thursday/labels{/name}","releases_url":"https://api.github.com/repos/hbellows/black_thursday/releases{/id}","deployments_url":"https://api.github.com/repos/hbellows/black_thursday/deployments","created_at":"2018-07-20T19:59:40Z","updated_at":"2018-08-01T15:57:34Z","pushed_at":"2018-08-01T16:01:53Z","git_url":"git://github.com/hbellows/black_thursday.git","ssh_url":"git@github.com:hbellows/black_thursday.git","clone_url":"https://github.com/hbellows/black_thursday.git","svn_url":"https://github.com/hbellows/black_thursday","homepage":null,"size":1882,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":3,"license":null,"forks":0,"open_issues":3,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/hbellows/black_thursday/pulls/97"},"html":{"href":"https://github.com/hbellows/black_thursday/pull/97"},"issue":{"href":"https://api.github.com/repos/hbellows/black_thursday/issues/97"},"comments":{"href":"https://api.github.com/repos/hbellows/black_thursday/issues/97/comments"},"review_comments":{"href":"https://api.github.com/repos/hbellows/black_thursday/pulls/97/comments"},"review_comment":{"href":"https://api.github.com/repos/hbellows/black_thursday/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/hbellows/black_thursday/pulls/97/commits"},"statuses":{"href":"https://api.github.com/repos/hbellows/black_thursday/statuses/29f5d6195509f9fc5773338222f912eb1c861ac5"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"houndci-bot"}}