{"action":"created","comment":{"url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/pulls/comments/206705402","pull_request_review_id":142172047,"id":206705402,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwNjcwNTQwMg==","diff_hunk":"@@ -138,5 +144,94 @@ def average_item_price\n     end \n     count = @item_repository.all.count \n     (sum / count).round(2)\n+  end\n+  \n+  def average_invoices_per_merchant_standard_deviation # => 3.29\n+    @merchant_id_invoice_counts_std_dev =\n+    (Math.sqrt(sum_of_inv_differences_squared / @merchant_repository.all.count)).round(2)\n+  end \n+  \n+  # helper to average_invoices_per_merchant_standard_deviation\n+  def sum_of_inv_differences_squared\n+    merchant_id_invoice_counter\n+    avg = average_invoices_per_merchant\n+    counts = @merchant_id_invoice_counts\n+    sum = 0.00\n+    @merchant_repository.all.each do |merchant|\n+      sum += (counts[merchant.id].to_f - avg.to_f)**2\n+    end  \n+    return sum.round(2)\n+  end\n+  \n+  # helper to sum_of_inv_differences_squared\n+  def merchant_id_invoice_counter\n+    m_invoice_count = Hash.new(0)\n+    @merchant_repository.all.map do |merchant|\n+      m_invoices = @invoice_repository.all.find_all do |invoice|\n+        invoice.merchant_id == merchant.id \n+        # m_items   \n+      end\n+      m_invoice_count[merchant.id] += m_invoices.count\n+    end\n+    @merchant_id_invoice_counts = m_invoice_count \n+  end\n+  \n+  # helper to sum_of_inv_differences_squared\n+  def average_invoices_per_merchant\n+    (@invoice_repository.all.count.to_f / @merchant_repository.all.count.to_f).round(2)\n+  end\n+  \n+  def top_merchants_by_invoice_count    \n+    ids_with_high_invoice_count.map do |id_array| \n+      @merchant_repository.all.find do |merchant|\n+        merchant.id == id_array[0]\n+      end\n+    end\n+  end \n+  \n+  # helper to top_merchants_by_invoice_count\n+  def ids_with_high_invoice_count\n+    merchant_id_invoice_counter\n+    average_invoices_per_merchant_standard_deviation\n+    id_high_invoices = @merchant_id_invoice_counts.find_all do |id, count|\n+      count > ((@merchant_id_invoice_counts_std_dev) * 2) + average_invoices_per_merchant\n+    end\n+    return id_high_invoices\n+  end\n+  \n+  def bottom_merchants_by_invoice_count    \n+    ids_with_low_invoice_count.map do |id_array| \n+      @merchant_repository.all.find do |merchant|\n+        merchant.id == id_array[0]\n+      end\n+    end\n+  end ","path":"lib/sales_analyst.rb","position":69,"original_position":87,"commit_id":"682fae2cf4e835b49b59aa353f91018912a80985","original_commit_id":"682fae2cf4e835b49b59aa353f91018912a80985","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/TrailingWhitespace: Trailing whitespace detected.","created_at":"2018-07-31T22:38:09Z","updated_at":"2018-07-31T22:38:10Z","html_url":"https://github.com/KellyMarcilliat/black_thursday/pull/25#discussion_r206705402","pull_request_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/pulls/25","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/KellyMarcilliat/black_thursday/pulls/comments/206705402"},"html":{"href":"https://github.com/KellyMarcilliat/black_thursday/pull/25#discussion_r206705402"},"pull_request":{"href":"https://api.github.com/repos/KellyMarcilliat/black_thursday/pulls/25"}}},"pull_request":{"url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/pulls/25","id":205262008,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA1MjYyMDA4","html_url":"https://github.com/KellyMarcilliat/black_thursday/pull/25","diff_url":"https://github.com/KellyMarcilliat/black_thursday/pull/25.diff","patch_url":"https://github.com/KellyMarcilliat/black_thursday/pull/25.patch","issue_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/issues/25","number":25,"state":"closed","locked":false,"title":"Sales analyst k 7","user":{"login":"KellyMarcilliat","id":25465205,"node_id":"MDQ6VXNlcjI1NDY1MjA1","avatar_url":"https://avatars0.githubusercontent.com/u/25465205?v=4","gravatar_id":"","url":"https://api.github.com/users/KellyMarcilliat","html_url":"https://github.com/KellyMarcilliat","followers_url":"https://api.github.com/users/KellyMarcilliat/followers","following_url":"https://api.github.com/users/KellyMarcilliat/following{/other_user}","gists_url":"https://api.github.com/users/KellyMarcilliat/gists{/gist_id}","starred_url":"https://api.github.com/users/KellyMarcilliat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KellyMarcilliat/subscriptions","organizations_url":"https://api.github.com/users/KellyMarcilliat/orgs","repos_url":"https://api.github.com/users/KellyMarcilliat/repos","events_url":"https://api.github.com/users/KellyMarcilliat/events{/privacy}","received_events_url":"https://api.github.com/users/KellyMarcilliat/received_events","type":"User","site_admin":false},"body":"Iteration 2 sales_analyst 80% complete","created_at":"2018-07-31T22:37:48Z","updated_at":"2018-07-31T22:38:10Z","closed_at":"2018-07-31T22:38:06Z","merged_at":"2018-07-31T22:38:06Z","merge_commit_sha":"580f2b0da8ff6c214ef8422094e75db3ccac446f","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/pulls/25/commits","review_comments_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/pulls/25/comments","review_comment_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/pulls/comments{/number}","comments_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/issues/25/comments","statuses_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/statuses/682fae2cf4e835b49b59aa353f91018912a80985","head":{"label":"KellyMarcilliat:sales_analyst_k_7","ref":"sales_analyst_k_7","sha":"682fae2cf4e835b49b59aa353f91018912a80985","user":{"login":"KellyMarcilliat","id":25465205,"node_id":"MDQ6VXNlcjI1NDY1MjA1","avatar_url":"https://avatars0.githubusercontent.com/u/25465205?v=4","gravatar_id":"","url":"https://api.github.com/users/KellyMarcilliat","html_url":"https://github.com/KellyMarcilliat","followers_url":"https://api.github.com/users/KellyMarcilliat/followers","following_url":"https://api.github.com/users/KellyMarcilliat/following{/other_user}","gists_url":"https://api.github.com/users/KellyMarcilliat/gists{/gist_id}","starred_url":"https://api.github.com/users/KellyMarcilliat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KellyMarcilliat/subscriptions","organizations_url":"https://api.github.com/users/KellyMarcilliat/orgs","repos_url":"https://api.github.com/users/KellyMarcilliat/repos","events_url":"https://api.github.com/users/KellyMarcilliat/events{/privacy}","received_events_url":"https://api.github.com/users/KellyMarcilliat/received_events","type":"User","site_admin":false},"repo":{"id":141838293,"node_id":"MDEwOlJlcG9zaXRvcnkxNDE4MzgyOTM=","name":"black_thursday","full_name":"KellyMarcilliat/black_thursday","owner":{"login":"KellyMarcilliat","id":25465205,"node_id":"MDQ6VXNlcjI1NDY1MjA1","avatar_url":"https://avatars0.githubusercontent.com/u/25465205?v=4","gravatar_id":"","url":"https://api.github.com/users/KellyMarcilliat","html_url":"https://github.com/KellyMarcilliat","followers_url":"https://api.github.com/users/KellyMarcilliat/followers","following_url":"https://api.github.com/users/KellyMarcilliat/following{/other_user}","gists_url":"https://api.github.com/users/KellyMarcilliat/gists{/gist_id}","starred_url":"https://api.github.com/users/KellyMarcilliat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KellyMarcilliat/subscriptions","organizations_url":"https://api.github.com/users/KellyMarcilliat/orgs","repos_url":"https://api.github.com/users/KellyMarcilliat/repos","events_url":"https://api.github.com/users/KellyMarcilliat/events{/privacy}","received_events_url":"https://api.github.com/users/KellyMarcilliat/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/KellyMarcilliat/black_thursday","description":null,"fork":true,"url":"https://api.github.com/repos/KellyMarcilliat/black_thursday","forks_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/forks","keys_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/keys{/key_id}","collaborators_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/teams","hooks_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/hooks","issue_events_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/issues/events{/number}","events_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/events","assignees_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/assignees{/user}","branches_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/branches{/branch}","tags_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/tags","blobs_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/git/refs{/sha}","trees_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/git/trees{/sha}","statuses_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/statuses/{sha}","languages_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/languages","stargazers_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/stargazers","contributors_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/contributors","subscribers_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/subscribers","subscription_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/subscription","commits_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/commits{/sha}","git_commits_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/git/commits{/sha}","comments_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/comments{/number}","issue_comment_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/issues/comments{/number}","contents_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/contents/{+path}","compare_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/compare/{base}...{head}","merges_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/merges","archive_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/downloads","issues_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/issues{/number}","pulls_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/pulls{/number}","milestones_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/milestones{/number}","notifications_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/labels{/name}","releases_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/releases{/id}","deployments_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/deployments","created_at":"2018-07-21T18:51:23Z","updated_at":"2018-07-31T22:38:08Z","pushed_at":"2018-07-31T22:38:06Z","git_url":"git://github.com/KellyMarcilliat/black_thursday.git","ssh_url":"git@github.com:KellyMarcilliat/black_thursday.git","clone_url":"https://github.com/KellyMarcilliat/black_thursday.git","svn_url":"https://github.com/KellyMarcilliat/black_thursday","homepage":null,"size":1766,"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":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"KellyMarcilliat:master","ref":"master","sha":"83f1a6e156b776f83c9678e45d36443a505d9937","user":{"login":"KellyMarcilliat","id":25465205,"node_id":"MDQ6VXNlcjI1NDY1MjA1","avatar_url":"https://avatars0.githubusercontent.com/u/25465205?v=4","gravatar_id":"","url":"https://api.github.com/users/KellyMarcilliat","html_url":"https://github.com/KellyMarcilliat","followers_url":"https://api.github.com/users/KellyMarcilliat/followers","following_url":"https://api.github.com/users/KellyMarcilliat/following{/other_user}","gists_url":"https://api.github.com/users/KellyMarcilliat/gists{/gist_id}","starred_url":"https://api.github.com/users/KellyMarcilliat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KellyMarcilliat/subscriptions","organizations_url":"https://api.github.com/users/KellyMarcilliat/orgs","repos_url":"https://api.github.com/users/KellyMarcilliat/repos","events_url":"https://api.github.com/users/KellyMarcilliat/events{/privacy}","received_events_url":"https://api.github.com/users/KellyMarcilliat/received_events","type":"User","site_admin":false},"repo":{"id":141838293,"node_id":"MDEwOlJlcG9zaXRvcnkxNDE4MzgyOTM=","name":"black_thursday","full_name":"KellyMarcilliat/black_thursday","owner":{"login":"KellyMarcilliat","id":25465205,"node_id":"MDQ6VXNlcjI1NDY1MjA1","avatar_url":"https://avatars0.githubusercontent.com/u/25465205?v=4","gravatar_id":"","url":"https://api.github.com/users/KellyMarcilliat","html_url":"https://github.com/KellyMarcilliat","followers_url":"https://api.github.com/users/KellyMarcilliat/followers","following_url":"https://api.github.com/users/KellyMarcilliat/following{/other_user}","gists_url":"https://api.github.com/users/KellyMarcilliat/gists{/gist_id}","starred_url":"https://api.github.com/users/KellyMarcilliat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KellyMarcilliat/subscriptions","organizations_url":"https://api.github.com/users/KellyMarcilliat/orgs","repos_url":"https://api.github.com/users/KellyMarcilliat/repos","events_url":"https://api.github.com/users/KellyMarcilliat/events{/privacy}","received_events_url":"https://api.github.com/users/KellyMarcilliat/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/KellyMarcilliat/black_thursday","description":null,"fork":true,"url":"https://api.github.com/repos/KellyMarcilliat/black_thursday","forks_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/forks","keys_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/keys{/key_id}","collaborators_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/teams","hooks_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/hooks","issue_events_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/issues/events{/number}","events_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/events","assignees_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/assignees{/user}","branches_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/branches{/branch}","tags_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/tags","blobs_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/git/refs{/sha}","trees_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/git/trees{/sha}","statuses_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/statuses/{sha}","languages_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/languages","stargazers_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/stargazers","contributors_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/contributors","subscribers_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/subscribers","subscription_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/subscription","commits_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/commits{/sha}","git_commits_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/git/commits{/sha}","comments_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/comments{/number}","issue_comment_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/issues/comments{/number}","contents_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/contents/{+path}","compare_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/compare/{base}...{head}","merges_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/merges","archive_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/downloads","issues_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/issues{/number}","pulls_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/pulls{/number}","milestones_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/milestones{/number}","notifications_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/labels{/name}","releases_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/releases{/id}","deployments_url":"https://api.github.com/repos/KellyMarcilliat/black_thursday/deployments","created_at":"2018-07-21T18:51:23Z","updated_at":"2018-07-31T22:38:08Z","pushed_at":"2018-07-31T22:38:06Z","git_url":"git://github.com/KellyMarcilliat/black_thursday.git","ssh_url":"git@github.com:KellyMarcilliat/black_thursday.git","clone_url":"https://github.com/KellyMarcilliat/black_thursday.git","svn_url":"https://github.com/KellyMarcilliat/black_thursday","homepage":null,"size":1766,"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":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/KellyMarcilliat/black_thursday/pulls/25"},"html":{"href":"https://github.com/KellyMarcilliat/black_thursday/pull/25"},"issue":{"href":"https://api.github.com/repos/KellyMarcilliat/black_thursday/issues/25"},"comments":{"href":"https://api.github.com/repos/KellyMarcilliat/black_thursday/issues/25/comments"},"review_comments":{"href":"https://api.github.com/repos/KellyMarcilliat/black_thursday/pulls/25/comments"},"review_comment":{"href":"https://api.github.com/repos/KellyMarcilliat/black_thursday/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/KellyMarcilliat/black_thursday/pulls/25/commits"},"statuses":{"href":"https://api.github.com/repos/KellyMarcilliat/black_thursday/statuses/682fae2cf4e835b49b59aa353f91018912a80985"}},"author_association":"OWNER"}}
{"actor":{"display_login":"houndci-bot"}}