{"action":"created","comment":{"url":"https://api.github.com/repos/IgorShkidchenko/rg_library/pulls/comments/230025653","pull_request_review_id":170658810,"id":230025653,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzMDAyNTY1Mw==","diff_hunk":"@@ -0,0 +1,55 @@\n+# frozen_string_literal: true\n+\n+module Statistics # :nodoc:\n+  def finder(num, klass = 'book')\n+    arr = []\n+    @orders.each { |obj| arr << obj.reader.name } if klass == 'readers'\n+    @orders.each { |obj| arr << obj.book.title } if klass == 'book'\n+    if klass == 'uniq'\n+      uniq = @orders.uniq { |obj| [obj.book, obj.reader] }\n+      uniq.each { |obj| arr << obj.book.title }\n+    end\n+    counted = arr.inject(Hash.new(0)) { |total, el| total[el] += 1; total }\n+    sorted = counted.sort_by { |_, v| v }.reverse.first(num).to_h\n+    if klass == 'readers'\n+      sorted.each { |k, v| puts \"#{k} read #{v > 1 ? v.to_s + ' books' : 'one book'}\" }\n+    else\n+      sorted.each { |k, v| puts \"#{k} was ordered #{v > 1 ? v.to_s + ' times' : 'once'}\" }\n+    end\n+  end\n+\n+  def most_popular_books(num = 1)\n+    puts \"\\nBest-seller#{num > 1 ? 's are' : ' is'}\"\n+    finder(num)\n+  end\n+\n+  def top_reader(num = 1)\n+    puts \"\\nGreat mind#{num > 1 ? 's are' : ' is'}\"\n+    finder(num, 'readers')\n+  end\n+  \n+  def number_of_readers(num = 3)\n+    puts \"\\nUniq books are\"\n+    finder(num, 'uniq')\n+  end\n+\n+  def save_to_db\n+    library_db = [@books, @authors, @readers, @orders]\n+    File.open('./data_base/database.yaml', 'w') { |f| f.write library_db.to_yaml }\n+  end\n+\n+  def load_db\n+    base = YAML.load(File.read('./data_base/database.yaml'))\n+    base.each { |inner| inner.each { |more| add_to_lib(more) } } unless base == false\n+  end\n+\n+  def add_to_lib(arg)","path":"library_controller/statistics.rb","position":48,"original_position":46,"commit_id":"e9147b3ed15668e442f9b6cb5576c627cd4f2e35","original_commit_id":"76e1823e64121b0288953a6cc9c6fcc9f0f91b83","user":{"login":"dzemlianoi-double","id":36458127,"node_id":"MDQ6VXNlcjM2NDU4MTI3","avatar_url":"https://avatars0.githubusercontent.com/u/36458127?v=4","gravatar_id":"","url":"https://api.github.com/users/dzemlianoi-double","html_url":"https://github.com/dzemlianoi-double","followers_url":"https://api.github.com/users/dzemlianoi-double/followers","following_url":"https://api.github.com/users/dzemlianoi-double/following{/other_user}","gists_url":"https://api.github.com/users/dzemlianoi-double/gists{/gist_id}","starred_url":"https://api.github.com/users/dzemlianoi-double/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dzemlianoi-double/subscriptions","organizations_url":"https://api.github.com/users/dzemlianoi-double/orgs","repos_url":"https://api.github.com/users/dzemlianoi-double/repos","events_url":"https://api.github.com/users/dzemlianoi-double/events{/privacy}","received_events_url":"https://api.github.com/users/dzemlianoi-double/received_events","type":"User","site_admin":false},"body":"don't shorten the words which are short by default.\r\nadd_to_lib -> add\r\nor\r\nadd_to_lib -> add_to_library","created_at":"2018-11-01T12:28:18Z","updated_at":"2018-11-01T12:28:38Z","html_url":"https://github.com/IgorShkidchenko/rg_library/pull/1#discussion_r230025653","pull_request_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/pulls/1","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/IgorShkidchenko/rg_library/pulls/comments/230025653"},"html":{"href":"https://github.com/IgorShkidchenko/rg_library/pull/1#discussion_r230025653"},"pull_request":{"href":"https://api.github.com/repos/IgorShkidchenko/rg_library/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/IgorShkidchenko/rg_library/pulls/1","id":226403609,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI2NDAzNjA5","html_url":"https://github.com/IgorShkidchenko/rg_library/pull/1","diff_url":"https://github.com/IgorShkidchenko/rg_library/pull/1.diff","patch_url":"https://github.com/IgorShkidchenko/rg_library/pull/1.patch","issue_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/issues/1","number":1,"state":"open","locked":false,"title":"for review","user":{"login":"IgorShkidchenko","id":34743391,"node_id":"MDQ6VXNlcjM0NzQzMzkx","avatar_url":"https://avatars1.githubusercontent.com/u/34743391?v=4","gravatar_id":"","url":"https://api.github.com/users/IgorShkidchenko","html_url":"https://github.com/IgorShkidchenko","followers_url":"https://api.github.com/users/IgorShkidchenko/followers","following_url":"https://api.github.com/users/IgorShkidchenko/following{/other_user}","gists_url":"https://api.github.com/users/IgorShkidchenko/gists{/gist_id}","starred_url":"https://api.github.com/users/IgorShkidchenko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IgorShkidchenko/subscriptions","organizations_url":"https://api.github.com/users/IgorShkidchenko/orgs","repos_url":"https://api.github.com/users/IgorShkidchenko/repos","events_url":"https://api.github.com/users/IgorShkidchenko/events{/privacy}","received_events_url":"https://api.github.com/users/IgorShkidchenko/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-10-28T22:47:05Z","updated_at":"2018-11-01T12:28:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8478ebe72c36aeecbae48677814a5a32b6616418","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/pulls/1/commits","review_comments_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/pulls/1/comments","review_comment_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/pulls/comments{/number}","comments_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/issues/1/comments","statuses_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/statuses/e9147b3ed15668e442f9b6cb5576c627cd4f2e35","head":{"label":"IgorShkidchenko:develop","ref":"develop","sha":"e9147b3ed15668e442f9b6cb5576c627cd4f2e35","user":{"login":"IgorShkidchenko","id":34743391,"node_id":"MDQ6VXNlcjM0NzQzMzkx","avatar_url":"https://avatars1.githubusercontent.com/u/34743391?v=4","gravatar_id":"","url":"https://api.github.com/users/IgorShkidchenko","html_url":"https://github.com/IgorShkidchenko","followers_url":"https://api.github.com/users/IgorShkidchenko/followers","following_url":"https://api.github.com/users/IgorShkidchenko/following{/other_user}","gists_url":"https://api.github.com/users/IgorShkidchenko/gists{/gist_id}","starred_url":"https://api.github.com/users/IgorShkidchenko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IgorShkidchenko/subscriptions","organizations_url":"https://api.github.com/users/IgorShkidchenko/orgs","repos_url":"https://api.github.com/users/IgorShkidchenko/repos","events_url":"https://api.github.com/users/IgorShkidchenko/events{/privacy}","received_events_url":"https://api.github.com/users/IgorShkidchenko/received_events","type":"User","site_admin":false},"repo":{"id":155123002,"node_id":"MDEwOlJlcG9zaXRvcnkxNTUxMjMwMDI=","name":"rg_library","full_name":"IgorShkidchenko/rg_library","private":false,"owner":{"login":"IgorShkidchenko","id":34743391,"node_id":"MDQ6VXNlcjM0NzQzMzkx","avatar_url":"https://avatars1.githubusercontent.com/u/34743391?v=4","gravatar_id":"","url":"https://api.github.com/users/IgorShkidchenko","html_url":"https://github.com/IgorShkidchenko","followers_url":"https://api.github.com/users/IgorShkidchenko/followers","following_url":"https://api.github.com/users/IgorShkidchenko/following{/other_user}","gists_url":"https://api.github.com/users/IgorShkidchenko/gists{/gist_id}","starred_url":"https://api.github.com/users/IgorShkidchenko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IgorShkidchenko/subscriptions","organizations_url":"https://api.github.com/users/IgorShkidchenko/orgs","repos_url":"https://api.github.com/users/IgorShkidchenko/repos","events_url":"https://api.github.com/users/IgorShkidchenko/events{/privacy}","received_events_url":"https://api.github.com/users/IgorShkidchenko/received_events","type":"User","site_admin":false},"html_url":"https://github.com/IgorShkidchenko/rg_library","description":null,"fork":false,"url":"https://api.github.com/repos/IgorShkidchenko/rg_library","forks_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/forks","keys_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/keys{/key_id}","collaborators_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/teams","hooks_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/hooks","issue_events_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/issues/events{/number}","events_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/events","assignees_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/assignees{/user}","branches_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/branches{/branch}","tags_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/tags","blobs_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/git/refs{/sha}","trees_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/git/trees{/sha}","statuses_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/statuses/{sha}","languages_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/languages","stargazers_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/stargazers","contributors_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/contributors","subscribers_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/subscribers","subscription_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/subscription","commits_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/commits{/sha}","git_commits_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/git/commits{/sha}","comments_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/comments{/number}","issue_comment_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/issues/comments{/number}","contents_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/contents/{+path}","compare_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/compare/{base}...{head}","merges_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/merges","archive_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/downloads","issues_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/issues{/number}","pulls_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/pulls{/number}","milestones_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/milestones{/number}","notifications_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/labels{/name}","releases_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/releases{/id}","deployments_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/deployments","created_at":"2018-10-28T22:43:40Z","updated_at":"2018-10-28T22:45:31Z","pushed_at":"2018-11-01T12:19:46Z","git_url":"git://github.com/IgorShkidchenko/rg_library.git","ssh_url":"git@github.com:IgorShkidchenko/rg_library.git","clone_url":"https://github.com/IgorShkidchenko/rg_library.git","svn_url":"https://github.com/IgorShkidchenko/rg_library","homepage":null,"size":8,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"IgorShkidchenko:master","ref":"master","sha":"1fb0b1dc480da13ca50bc3b3e8685429c67a6490","user":{"login":"IgorShkidchenko","id":34743391,"node_id":"MDQ6VXNlcjM0NzQzMzkx","avatar_url":"https://avatars1.githubusercontent.com/u/34743391?v=4","gravatar_id":"","url":"https://api.github.com/users/IgorShkidchenko","html_url":"https://github.com/IgorShkidchenko","followers_url":"https://api.github.com/users/IgorShkidchenko/followers","following_url":"https://api.github.com/users/IgorShkidchenko/following{/other_user}","gists_url":"https://api.github.com/users/IgorShkidchenko/gists{/gist_id}","starred_url":"https://api.github.com/users/IgorShkidchenko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IgorShkidchenko/subscriptions","organizations_url":"https://api.github.com/users/IgorShkidchenko/orgs","repos_url":"https://api.github.com/users/IgorShkidchenko/repos","events_url":"https://api.github.com/users/IgorShkidchenko/events{/privacy}","received_events_url":"https://api.github.com/users/IgorShkidchenko/received_events","type":"User","site_admin":false},"repo":{"id":155123002,"node_id":"MDEwOlJlcG9zaXRvcnkxNTUxMjMwMDI=","name":"rg_library","full_name":"IgorShkidchenko/rg_library","private":false,"owner":{"login":"IgorShkidchenko","id":34743391,"node_id":"MDQ6VXNlcjM0NzQzMzkx","avatar_url":"https://avatars1.githubusercontent.com/u/34743391?v=4","gravatar_id":"","url":"https://api.github.com/users/IgorShkidchenko","html_url":"https://github.com/IgorShkidchenko","followers_url":"https://api.github.com/users/IgorShkidchenko/followers","following_url":"https://api.github.com/users/IgorShkidchenko/following{/other_user}","gists_url":"https://api.github.com/users/IgorShkidchenko/gists{/gist_id}","starred_url":"https://api.github.com/users/IgorShkidchenko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IgorShkidchenko/subscriptions","organizations_url":"https://api.github.com/users/IgorShkidchenko/orgs","repos_url":"https://api.github.com/users/IgorShkidchenko/repos","events_url":"https://api.github.com/users/IgorShkidchenko/events{/privacy}","received_events_url":"https://api.github.com/users/IgorShkidchenko/received_events","type":"User","site_admin":false},"html_url":"https://github.com/IgorShkidchenko/rg_library","description":null,"fork":false,"url":"https://api.github.com/repos/IgorShkidchenko/rg_library","forks_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/forks","keys_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/keys{/key_id}","collaborators_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/teams","hooks_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/hooks","issue_events_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/issues/events{/number}","events_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/events","assignees_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/assignees{/user}","branches_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/branches{/branch}","tags_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/tags","blobs_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/git/refs{/sha}","trees_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/git/trees{/sha}","statuses_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/statuses/{sha}","languages_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/languages","stargazers_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/stargazers","contributors_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/contributors","subscribers_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/subscribers","subscription_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/subscription","commits_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/commits{/sha}","git_commits_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/git/commits{/sha}","comments_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/comments{/number}","issue_comment_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/issues/comments{/number}","contents_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/contents/{+path}","compare_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/compare/{base}...{head}","merges_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/merges","archive_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/downloads","issues_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/issues{/number}","pulls_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/pulls{/number}","milestones_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/milestones{/number}","notifications_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/labels{/name}","releases_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/releases{/id}","deployments_url":"https://api.github.com/repos/IgorShkidchenko/rg_library/deployments","created_at":"2018-10-28T22:43:40Z","updated_at":"2018-10-28T22:45:31Z","pushed_at":"2018-11-01T12:19:46Z","git_url":"git://github.com/IgorShkidchenko/rg_library.git","ssh_url":"git@github.com:IgorShkidchenko/rg_library.git","clone_url":"https://github.com/IgorShkidchenko/rg_library.git","svn_url":"https://github.com/IgorShkidchenko/rg_library","homepage":null,"size":8,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/IgorShkidchenko/rg_library/pulls/1"},"html":{"href":"https://github.com/IgorShkidchenko/rg_library/pull/1"},"issue":{"href":"https://api.github.com/repos/IgorShkidchenko/rg_library/issues/1"},"comments":{"href":"https://api.github.com/repos/IgorShkidchenko/rg_library/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/IgorShkidchenko/rg_library/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/IgorShkidchenko/rg_library/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/IgorShkidchenko/rg_library/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/IgorShkidchenko/rg_library/statuses/e9147b3ed15668e442f9b6cb5576c627cd4f2e35"}},"author_association":"OWNER"}}
{"actor":{"display_login":"dzemlianoi-double"}}