{"action":"created","comment":{"url":"https://api.github.com/repos/osklyarenko/see_through/pulls/comments/58293632","id":58293632,"diff_hunk":"@@ -0,0 +1,174 @@\n+require 'active_record'\n+require 'json'\n+\n+def db_init\n+\n+  ActiveRecord::Base.logger = Logger.new(File.open('database.log', 'w'))\n+\n+  ActiveRecord::Base.establish_connection(\n+      :adapter => 'sqlite3',\n+      :database => 'data.db'\n+  )\n+\n+  ActiveRecord::Schema.define do\n+\n+    unless ActiveRecord::Base.connection.tables.include? 'pull_requests'\n+      create_table :pull_requests do |t|\n+        t.column :title, :string, :null => false\n+        t.column :pr_id, :string, :null => false\n+        t.column :author, :string, :null => false\n+        t.column :merged, :boolean, :null => false\n+        t.column :mergeable, :boolean, :null => true\n+        t.column :mergeable_state, :string, :null => true\n+        t.column :state, :string, :null => true\n+        t.column :pr_commentors, :string, :null => true\n+        t.column :committer, :string, :null => true\n+        t.column :labels, :string, :null => true\n+        t.column :created_at, :string, :null => true\n+        t.column :updated_at, :string, :null => true\n+        t.column :added_to_database, :string #:null => true\n+\n+      end\n+    end\n+\n+    unless ActiveRecord::Base.connection.tables.include? 'users'\n+      create_table :users do |table|\n+        table.column :user_login, :string, unique: true\n+        table.column :user_email, :string\n+        table.column :git_email, :string\n+        table.column :git_hub_id, :integer\n+        table.column :notify_at, :string\n+        table.column :daily_status, :boolean\n+      end\n+    end\n+\n+    unless ActiveRecord::Base.connection.tables.include? 'commentors'\n+      create_table :commentors do |table|\n+        table.column :pull_request_id, :integer #foreign key\n+        table.column :user_id, :string\n+      end\n+    end\n+\n+  end\n+end\n+\n+class User < ActiveRecord::Base\n+  belongs_to :commentors\n+end\n+\n+class PullRequest < ActiveRecord::Base\n+  has_many :commentors\n+end\n+\n+class Commentor < ActiveRecord::Base\n+  belongs_to :pull_request\n+  has_one :users\n+end\n+\n+def add_new_pull_request i, pr_data\n+  PullRequest.create(\n+      :title => i.title,\n+      :pr_id => i.number,\n+      :author => i.user.login,\n+      :merged => pr_data[:merged],\n+      :mergeable => pr_data[:mergeable],\n+      :mergeable_state => pr_data[:mergeable_state],\n+      :state => pr_data[:state],\n+      :pr_commentors => pr_data[:commentors].to_a.join(\", \"),\n+      :committer => pr_data[:committer].to_a.join(\", \"),\n+      :labels => pr_data[:label].to_a.join(\", \"),\n+      :created_at => pr_data[:created_at],\n+      :updated_at => pr_data[:updated_at],\n+      :added_to_database => Time.new,\n+\n+  )\n+\n+  commentors_list = pr_data[:commentors].to_a\n+  commentors_list.each do |c|\n+    user = User.where(user_login: c)\n+    Commentor.create(\n+        :pull_request_id => i.number,\n+        :user_id => user.first.id,\n+    )\n+  end\n+end\n+\n+def check i, pr_data","path":"DataBase.rb","position":96,"original_position":96,"commit_id":"720802eaf8877b196d431c5c1d2184450f73ec4e","original_commit_id":"720802eaf8877b196d431c5c1d2184450f73ec4e","user":{"login":"zdmytriv","id":1759112,"avatar_url":"https://avatars.githubusercontent.com/u/1759112?v=3","gravatar_id":"","url":"https://api.github.com/users/zdmytriv","html_url":"https://github.com/zdmytriv","followers_url":"https://api.github.com/users/zdmytriv/followers","following_url":"https://api.github.com/users/zdmytriv/following{/other_user}","gists_url":"https://api.github.com/users/zdmytriv/gists{/gist_id}","starred_url":"https://api.github.com/users/zdmytriv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zdmytriv/subscriptions","organizations_url":"https://api.github.com/users/zdmytriv/orgs","repos_url":"https://api.github.com/users/zdmytriv/repos","events_url":"https://api.github.com/users/zdmytriv/events{/privacy}","received_events_url":"https://api.github.com/users/zdmytriv/received_events","type":"User","site_admin":false},"body":"What doesn't this method check? Method name is not descriptive.\r\n\r\nWhat does parameter 'i' do? Add more descriptive name.","created_at":"2016-04-02T13:55:00Z","updated_at":"2016-04-02T13:55:00Z","html_url":"https://github.com/osklyarenko/see_through/pull/2#discussion_r58293632","pull_request_url":"https://api.github.com/repos/osklyarenko/see_through/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/osklyarenko/see_through/pulls/comments/58293632"},"html":{"href":"https://github.com/osklyarenko/see_through/pull/2#discussion_r58293632"},"pull_request":{"href":"https://api.github.com/repos/osklyarenko/see_through/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/osklyarenko/see_through/pulls/2","id":64662705,"html_url":"https://github.com/osklyarenko/see_through/pull/2","diff_url":"https://github.com/osklyarenko/see_through/pull/2.diff","patch_url":"https://github.com/osklyarenko/see_through/pull/2.patch","issue_url":"https://api.github.com/repos/osklyarenko/see_through/issues/2","number":2,"state":"open","locked":false,"title":"Refactor reporting","user":{"login":"yuramelesh","id":12019830,"avatar_url":"https://avatars.githubusercontent.com/u/12019830?v=3","gravatar_id":"","url":"https://api.github.com/users/yuramelesh","html_url":"https://github.com/yuramelesh","followers_url":"https://api.github.com/users/yuramelesh/followers","following_url":"https://api.github.com/users/yuramelesh/following{/other_user}","gists_url":"https://api.github.com/users/yuramelesh/gists{/gist_id}","starred_url":"https://api.github.com/users/yuramelesh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yuramelesh/subscriptions","organizations_url":"https://api.github.com/users/yuramelesh/orgs","repos_url":"https://api.github.com/users/yuramelesh/repos","events_url":"https://api.github.com/users/yuramelesh/events{/privacy}","received_events_url":"https://api.github.com/users/yuramelesh/received_events","type":"User","site_admin":false},"body":"- checking users for existing in database;\r\n- checking updates for pull requests;\r\n- calculating time of non mergeable and unstable pull requests;\r\n- mail style re factoring;","created_at":"2016-03-30T17:07:59Z","updated_at":"2016-04-02T13:55:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7606422ec1cb7da3418faea4adb07eba31585cd5","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/osklyarenko/see_through/pulls/2/commits","review_comments_url":"https://api.github.com/repos/osklyarenko/see_through/pulls/2/comments","review_comment_url":"https://api.github.com/repos/osklyarenko/see_through/pulls/comments{/number}","comments_url":"https://api.github.com/repos/osklyarenko/see_through/issues/2/comments","statuses_url":"https://api.github.com/repos/osklyarenko/see_through/statuses/720802eaf8877b196d431c5c1d2184450f73ec4e","head":{"label":"yuramelesh:refactor-reporting","ref":"refactor-reporting","sha":"720802eaf8877b196d431c5c1d2184450f73ec4e","user":{"login":"yuramelesh","id":12019830,"avatar_url":"https://avatars.githubusercontent.com/u/12019830?v=3","gravatar_id":"","url":"https://api.github.com/users/yuramelesh","html_url":"https://github.com/yuramelesh","followers_url":"https://api.github.com/users/yuramelesh/followers","following_url":"https://api.github.com/users/yuramelesh/following{/other_user}","gists_url":"https://api.github.com/users/yuramelesh/gists{/gist_id}","starred_url":"https://api.github.com/users/yuramelesh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yuramelesh/subscriptions","organizations_url":"https://api.github.com/users/yuramelesh/orgs","repos_url":"https://api.github.com/users/yuramelesh/repos","events_url":"https://api.github.com/users/yuramelesh/events{/privacy}","received_events_url":"https://api.github.com/users/yuramelesh/received_events","type":"User","site_admin":false},"repo":{"id":54900828,"name":"see_through","full_name":"yuramelesh/see_through","owner":{"login":"yuramelesh","id":12019830,"avatar_url":"https://avatars.githubusercontent.com/u/12019830?v=3","gravatar_id":"","url":"https://api.github.com/users/yuramelesh","html_url":"https://github.com/yuramelesh","followers_url":"https://api.github.com/users/yuramelesh/followers","following_url":"https://api.github.com/users/yuramelesh/following{/other_user}","gists_url":"https://api.github.com/users/yuramelesh/gists{/gist_id}","starred_url":"https://api.github.com/users/yuramelesh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yuramelesh/subscriptions","organizations_url":"https://api.github.com/users/yuramelesh/orgs","repos_url":"https://api.github.com/users/yuramelesh/repos","events_url":"https://api.github.com/users/yuramelesh/events{/privacy}","received_events_url":"https://api.github.com/users/yuramelesh/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/yuramelesh/see_through","description":"","fork":true,"url":"https://api.github.com/repos/yuramelesh/see_through","forks_url":"https://api.github.com/repos/yuramelesh/see_through/forks","keys_url":"https://api.github.com/repos/yuramelesh/see_through/keys{/key_id}","collaborators_url":"https://api.github.com/repos/yuramelesh/see_through/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/yuramelesh/see_through/teams","hooks_url":"https://api.github.com/repos/yuramelesh/see_through/hooks","issue_events_url":"https://api.github.com/repos/yuramelesh/see_through/issues/events{/number}","events_url":"https://api.github.com/repos/yuramelesh/see_through/events","assignees_url":"https://api.github.com/repos/yuramelesh/see_through/assignees{/user}","branches_url":"https://api.github.com/repos/yuramelesh/see_through/branches{/branch}","tags_url":"https://api.github.com/repos/yuramelesh/see_through/tags","blobs_url":"https://api.github.com/repos/yuramelesh/see_through/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/yuramelesh/see_through/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/yuramelesh/see_through/git/refs{/sha}","trees_url":"https://api.github.com/repos/yuramelesh/see_through/git/trees{/sha}","statuses_url":"https://api.github.com/repos/yuramelesh/see_through/statuses/{sha}","languages_url":"https://api.github.com/repos/yuramelesh/see_through/languages","stargazers_url":"https://api.github.com/repos/yuramelesh/see_through/stargazers","contributors_url":"https://api.github.com/repos/yuramelesh/see_through/contributors","subscribers_url":"https://api.github.com/repos/yuramelesh/see_through/subscribers","subscription_url":"https://api.github.com/repos/yuramelesh/see_through/subscription","commits_url":"https://api.github.com/repos/yuramelesh/see_through/commits{/sha}","git_commits_url":"https://api.github.com/repos/yuramelesh/see_through/git/commits{/sha}","comments_url":"https://api.github.com/repos/yuramelesh/see_through/comments{/number}","issue_comment_url":"https://api.github.com/repos/yuramelesh/see_through/issues/comments{/number}","contents_url":"https://api.github.com/repos/yuramelesh/see_through/contents/{+path}","compare_url":"https://api.github.com/repos/yuramelesh/see_through/compare/{base}...{head}","merges_url":"https://api.github.com/repos/yuramelesh/see_through/merges","archive_url":"https://api.github.com/repos/yuramelesh/see_through/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/yuramelesh/see_through/downloads","issues_url":"https://api.github.com/repos/yuramelesh/see_through/issues{/number}","pulls_url":"https://api.github.com/repos/yuramelesh/see_through/pulls{/number}","milestones_url":"https://api.github.com/repos/yuramelesh/see_through/milestones{/number}","notifications_url":"https://api.github.com/repos/yuramelesh/see_through/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/yuramelesh/see_through/labels{/name}","releases_url":"https://api.github.com/repos/yuramelesh/see_through/releases{/id}","deployments_url":"https://api.github.com/repos/yuramelesh/see_through/deployments","created_at":"2016-03-28T15:09:49Z","updated_at":"2016-03-28T15:09:50Z","pushed_at":"2016-04-01T11:21:12Z","git_url":"git://github.com/yuramelesh/see_through.git","ssh_url":"git@github.com:yuramelesh/see_through.git","clone_url":"https://github.com/yuramelesh/see_through.git","svn_url":"https://github.com/yuramelesh/see_through","homepage":null,"size":16,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"osklyarenko:master","ref":"master","sha":"7593a5200c4fe6b8c52a2dadbd1f2df016f5f22a","user":{"login":"osklyarenko","id":861907,"avatar_url":"https://avatars.githubusercontent.com/u/861907?v=3","gravatar_id":"","url":"https://api.github.com/users/osklyarenko","html_url":"https://github.com/osklyarenko","followers_url":"https://api.github.com/users/osklyarenko/followers","following_url":"https://api.github.com/users/osklyarenko/following{/other_user}","gists_url":"https://api.github.com/users/osklyarenko/gists{/gist_id}","starred_url":"https://api.github.com/users/osklyarenko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/osklyarenko/subscriptions","organizations_url":"https://api.github.com/users/osklyarenko/orgs","repos_url":"https://api.github.com/users/osklyarenko/repos","events_url":"https://api.github.com/users/osklyarenko/events{/privacy}","received_events_url":"https://api.github.com/users/osklyarenko/received_events","type":"User","site_admin":false},"repo":{"id":53846848,"name":"see_through","full_name":"osklyarenko/see_through","owner":{"login":"osklyarenko","id":861907,"avatar_url":"https://avatars.githubusercontent.com/u/861907?v=3","gravatar_id":"","url":"https://api.github.com/users/osklyarenko","html_url":"https://github.com/osklyarenko","followers_url":"https://api.github.com/users/osklyarenko/followers","following_url":"https://api.github.com/users/osklyarenko/following{/other_user}","gists_url":"https://api.github.com/users/osklyarenko/gists{/gist_id}","starred_url":"https://api.github.com/users/osklyarenko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/osklyarenko/subscriptions","organizations_url":"https://api.github.com/users/osklyarenko/orgs","repos_url":"https://api.github.com/users/osklyarenko/repos","events_url":"https://api.github.com/users/osklyarenko/events{/privacy}","received_events_url":"https://api.github.com/users/osklyarenko/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/osklyarenko/see_through","description":"","fork":false,"url":"https://api.github.com/repos/osklyarenko/see_through","forks_url":"https://api.github.com/repos/osklyarenko/see_through/forks","keys_url":"https://api.github.com/repos/osklyarenko/see_through/keys{/key_id}","collaborators_url":"https://api.github.com/repos/osklyarenko/see_through/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/osklyarenko/see_through/teams","hooks_url":"https://api.github.com/repos/osklyarenko/see_through/hooks","issue_events_url":"https://api.github.com/repos/osklyarenko/see_through/issues/events{/number}","events_url":"https://api.github.com/repos/osklyarenko/see_through/events","assignees_url":"https://api.github.com/repos/osklyarenko/see_through/assignees{/user}","branches_url":"https://api.github.com/repos/osklyarenko/see_through/branches{/branch}","tags_url":"https://api.github.com/repos/osklyarenko/see_through/tags","blobs_url":"https://api.github.com/repos/osklyarenko/see_through/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/osklyarenko/see_through/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/osklyarenko/see_through/git/refs{/sha}","trees_url":"https://api.github.com/repos/osklyarenko/see_through/git/trees{/sha}","statuses_url":"https://api.github.com/repos/osklyarenko/see_through/statuses/{sha}","languages_url":"https://api.github.com/repos/osklyarenko/see_through/languages","stargazers_url":"https://api.github.com/repos/osklyarenko/see_through/stargazers","contributors_url":"https://api.github.com/repos/osklyarenko/see_through/contributors","subscribers_url":"https://api.github.com/repos/osklyarenko/see_through/subscribers","subscription_url":"https://api.github.com/repos/osklyarenko/see_through/subscription","commits_url":"https://api.github.com/repos/osklyarenko/see_through/commits{/sha}","git_commits_url":"https://api.github.com/repos/osklyarenko/see_through/git/commits{/sha}","comments_url":"https://api.github.com/repos/osklyarenko/see_through/comments{/number}","issue_comment_url":"https://api.github.com/repos/osklyarenko/see_through/issues/comments{/number}","contents_url":"https://api.github.com/repos/osklyarenko/see_through/contents/{+path}","compare_url":"https://api.github.com/repos/osklyarenko/see_through/compare/{base}...{head}","merges_url":"https://api.github.com/repos/osklyarenko/see_through/merges","archive_url":"https://api.github.com/repos/osklyarenko/see_through/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/osklyarenko/see_through/downloads","issues_url":"https://api.github.com/repos/osklyarenko/see_through/issues{/number}","pulls_url":"https://api.github.com/repos/osklyarenko/see_through/pulls{/number}","milestones_url":"https://api.github.com/repos/osklyarenko/see_through/milestones{/number}","notifications_url":"https://api.github.com/repos/osklyarenko/see_through/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/osklyarenko/see_through/labels{/name}","releases_url":"https://api.github.com/repos/osklyarenko/see_through/releases{/id}","deployments_url":"https://api.github.com/repos/osklyarenko/see_through/deployments","created_at":"2016-03-14T10:23:23Z","updated_at":"2016-03-23T10:28:12Z","pushed_at":"2016-04-01T11:21:12Z","git_url":"git://github.com/osklyarenko/see_through.git","ssh_url":"git@github.com:osklyarenko/see_through.git","clone_url":"https://github.com/osklyarenko/see_through.git","svn_url":"https://github.com/osklyarenko/see_through","homepage":null,"size":4,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":2,"forks":1,"open_issues":2,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/osklyarenko/see_through/pulls/2"},"html":{"href":"https://github.com/osklyarenko/see_through/pull/2"},"issue":{"href":"https://api.github.com/repos/osklyarenko/see_through/issues/2"},"comments":{"href":"https://api.github.com/repos/osklyarenko/see_through/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/osklyarenko/see_through/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/osklyarenko/see_through/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/osklyarenko/see_through/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/osklyarenko/see_through/statuses/720802eaf8877b196d431c5c1d2184450f73ec4e"}}}}