{"action":"created","comment":{"url":"https://api.github.com/repos/ruby-bench/ruby-bench-web/pulls/comments/121170920","pull_request_review_id":43203998,"id":121170920,"diff_hunk":"@@ -0,0 +1,46 @@\n+class ManualRunner\n+  def initialize(repo)\n+    raise \"Repo doesn't exist\" unless Repo.exists?(repo.id)\n+    @repo = repo\n+    @octokit = Octokit::Client.new(access_token: Rails.application.secrets.github_api_token)\n+  end\n+\n+  def run_last(commits_count)\n+    run_paginated(commits_count)\n+  end\n+\n+  private\n+\n+  def run_paginated(commits_count, page = 1)\n+    unless (commits_count <= 0)\n+      count_run = run_commits(page)\n+      run_paginated(commits_count - count_run, page + 1)\n+    end\n+  end\n+\n+  def run_commits(page)\n+    fetched_commits = @octokit.commits(\"#{@repo.organization.name}/#{@repo.name}\", per_page: 100, page: page)\n+    formatted_commits = format_commits(fetched_commits)\n+    CommitsRunner.run(formatted_commits)\n+\n+    fetched_commits.count\n+  end\n+\n+  def format_commits(commits)\n+    commits.map do |commit|\n+      {\n+        sha: commit['sha'],\n+        message: commit['commit']['message'],\n+        repo: {\n+          id: @repo.id,\n+          name: @repo.name\n+        },\n+        url: commit['html_url'],\n+        created_at: commit['commit']['author']['date'],\n+        author: {\n+          name: commit['commit']['author']['name']\n+        }\n+      }","path":"app/services/manual_runner.rb","position":43,"original_position":43,"commit_id":"b5d54da6d7bd6c7481ffeca06b5ac77d8d29dd63","original_commit_id":"b5d54da6d7bd6c7481ffeca06b5ac77d8d29dd63","user":{"login":"noahgibbs","id":82408,"avatar_url":"https://avatars2.githubusercontent.com/u/82408?v=3","gravatar_id":"","url":"https://api.github.com/users/noahgibbs","html_url":"https://github.com/noahgibbs","followers_url":"https://api.github.com/users/noahgibbs/followers","following_url":"https://api.github.com/users/noahgibbs/following{/other_user}","gists_url":"https://api.github.com/users/noahgibbs/gists{/gist_id}","starred_url":"https://api.github.com/users/noahgibbs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/noahgibbs/subscriptions","organizations_url":"https://api.github.com/users/noahgibbs/orgs","repos_url":"https://api.github.com/users/noahgibbs/repos","events_url":"https://api.github.com/users/noahgibbs/events{/privacy}","received_events_url":"https://api.github.com/users/noahgibbs/received_events","type":"User","site_admin":false},"body":"2000 commits (so 2000 times creating a new hash table) just won't be a big deal on that scale.","created_at":"2017-06-09T16:39:53Z","updated_at":"2017-06-09T16:39:53Z","html_url":"https://github.com/ruby-bench/ruby-bench-web/pull/210#discussion_r121170920","pull_request_url":"https://api.github.com/repos/ruby-bench/ruby-bench-web/pulls/210","_links":{"self":{"href":"https://api.github.com/repos/ruby-bench/ruby-bench-web/pulls/comments/121170920"},"html":{"href":"https://github.com/ruby-bench/ruby-bench-web/pull/210#discussion_r121170920"},"pull_request":{"href":"https://api.github.com/repos/ruby-bench/ruby-bench-web/pulls/210"}}},"pull_request":{"url":"https://api.github.com/repos/ruby-bench/ruby-bench-web/pulls/210","id":124685929,"html_url":"https://github.com/ruby-bench/ruby-bench-web/pull/210","diff_url":"https://github.com/ruby-bench/ruby-bench-web/pull/210.diff","patch_url":"https://github.com/ruby-bench/ruby-bench-web/pull/210.patch","issue_url":"https://api.github.com/repos/ruby-bench/ruby-bench-web/issues/210","number":210,"state":"open","locked":false,"title":"Add manual runner","user":{"login":"bmarkons","id":9396752,"avatar_url":"https://avatars3.githubusercontent.com/u/9396752?v=3","gravatar_id":"","url":"https://api.github.com/users/bmarkons","html_url":"https://github.com/bmarkons","followers_url":"https://api.github.com/users/bmarkons/followers","following_url":"https://api.github.com/users/bmarkons/following{/other_user}","gists_url":"https://api.github.com/users/bmarkons/gists{/gist_id}","starred_url":"https://api.github.com/users/bmarkons/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bmarkons/subscriptions","organizations_url":"https://api.github.com/users/bmarkons/orgs","repos_url":"https://api.github.com/users/bmarkons/repos","events_url":"https://api.github.com/users/bmarkons/events{/privacy}","received_events_url":"https://api.github.com/users/bmarkons/received_events","type":"User","site_admin":false},"body":"I needed to run Sequel benchmarks for last 2000 commits. So far I could do it in production console in a pretty hacky (unsafe) way. Therefore I want to add `app/services/manual_runner.rb` which would fetch, store and run last 2000 commits from github api. That way we could run last number of commits manually in a tested way.","created_at":"2017-06-08T15:57:05Z","updated_at":"2017-06-09T16:39:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a19b284359e283360e2b30856d5aef0a2be366a2","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/ruby-bench/ruby-bench-web/pulls/210/commits","review_comments_url":"https://api.github.com/repos/ruby-bench/ruby-bench-web/pulls/210/comments","review_comment_url":"https://api.github.com/repos/ruby-bench/ruby-bench-web/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ruby-bench/ruby-bench-web/issues/210/comments","statuses_url":"https://api.github.com/repos/ruby-bench/ruby-bench-web/statuses/b5d54da6d7bd6c7481ffeca06b5ac77d8d29dd63","head":{"label":"bmarkons:manual-runner","ref":"manual-runner","sha":"b5d54da6d7bd6c7481ffeca06b5ac77d8d29dd63","user":{"login":"bmarkons","id":9396752,"avatar_url":"https://avatars3.githubusercontent.com/u/9396752?v=3","gravatar_id":"","url":"https://api.github.com/users/bmarkons","html_url":"https://github.com/bmarkons","followers_url":"https://api.github.com/users/bmarkons/followers","following_url":"https://api.github.com/users/bmarkons/following{/other_user}","gists_url":"https://api.github.com/users/bmarkons/gists{/gist_id}","starred_url":"https://api.github.com/users/bmarkons/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bmarkons/subscriptions","organizations_url":"https://api.github.com/users/bmarkons/orgs","repos_url":"https://api.github.com/users/bmarkons/repos","events_url":"https://api.github.com/users/bmarkons/events{/privacy}","received_events_url":"https://api.github.com/users/bmarkons/received_events","type":"User","site_admin":false},"repo":{"id":90880821,"name":"ruby-bench-web","full_name":"bmarkons/ruby-bench-web","owner":{"login":"bmarkons","id":9396752,"avatar_url":"https://avatars3.githubusercontent.com/u/9396752?v=3","gravatar_id":"","url":"https://api.github.com/users/bmarkons","html_url":"https://github.com/bmarkons","followers_url":"https://api.github.com/users/bmarkons/followers","following_url":"https://api.github.com/users/bmarkons/following{/other_user}","gists_url":"https://api.github.com/users/bmarkons/gists{/gist_id}","starred_url":"https://api.github.com/users/bmarkons/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bmarkons/subscriptions","organizations_url":"https://api.github.com/users/bmarkons/orgs","repos_url":"https://api.github.com/users/bmarkons/repos","events_url":"https://api.github.com/users/bmarkons/events{/privacy}","received_events_url":"https://api.github.com/users/bmarkons/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bmarkons/ruby-bench-web","description":"Long Running Ruby Benchmarks","fork":true,"url":"https://api.github.com/repos/bmarkons/ruby-bench-web","forks_url":"https://api.github.com/repos/bmarkons/ruby-bench-web/forks","keys_url":"https://api.github.com/repos/bmarkons/ruby-bench-web/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bmarkons/ruby-bench-web/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bmarkons/ruby-bench-web/teams","hooks_url":"https://api.github.com/repos/bmarkons/ruby-bench-web/hooks","issue_events_url":"https://api.github.com/repos/bmarkons/ruby-bench-web/issues/events{/number}","events_url":"https://api.github.com/repos/bmarkons/ruby-bench-web/events","assignees_url":"https://api.github.com/repos/bmarkons/ruby-bench-web/assignees{/user}","branches_url":"https://api.github.com/repos/bmarkons/ruby-bench-web/branches{/branch}","tags_url":"https://api.github.com/repos/bmarkons/ruby-bench-web/tags","blobs_url":"https://api.github.com/repos/bmarkons/ruby-bench-web/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bmarkons/ruby-bench-web/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bmarkons/ruby-bench-web/git/refs{/sha}","trees_url":"https://api.github.com/repos/bmarkons/ruby-bench-web/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bmarkons/ruby-bench-web/statuses/{sha}","languages_url":"https://api.github.com/repos/bmarkons/ruby-bench-web/languages","stargazers_url":"https://api.github.com/repos/bmarkons/ruby-bench-web/stargazers","contributors_url":"https://api.github.com/repos/bmarkons/ruby-bench-web/contributors","subscribers_url":"https://api.github.com/repos/bmarkons/ruby-bench-web/subscribers","subscription_url":"https://api.github.com/repos/bmarkons/ruby-bench-web/subscription","commits_url":"https://api.github.com/repos/bmarkons/ruby-bench-web/commits{/sha}","git_commits_url":"https://api.github.com/repos/bmarkons/ruby-bench-web/git/commits{/sha}","comments_url":"https://api.github.com/repos/bmarkons/ruby-bench-web/comments{/number}","issue_comment_url":"https://api.github.com/repos/bmarkons/ruby-bench-web/issues/comments{/number}","contents_url":"https://api.github.com/repos/bmarkons/ruby-bench-web/contents/{+path}","compare_url":"https://api.github.com/repos/bmarkons/ruby-bench-web/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bmarkons/ruby-bench-web/merges","archive_url":"https://api.github.com/repos/bmarkons/ruby-bench-web/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bmarkons/ruby-bench-web/downloads","issues_url":"https://api.github.com/repos/bmarkons/ruby-bench-web/issues{/number}","pulls_url":"https://api.github.com/repos/bmarkons/ruby-bench-web/pulls{/number}","milestones_url":"https://api.github.com/repos/bmarkons/ruby-bench-web/milestones{/number}","notifications_url":"https://api.github.com/repos/bmarkons/ruby-bench-web/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bmarkons/ruby-bench-web/labels{/name}","releases_url":"https://api.github.com/repos/bmarkons/ruby-bench-web/releases{/id}","deployments_url":"https://api.github.com/repos/bmarkons/ruby-bench-web/deployments","created_at":"2017-05-10T15:38:11Z","updated_at":"2017-05-10T15:38:13Z","pushed_at":"2017-06-09T15:19:35Z","git_url":"git://github.com/bmarkons/ruby-bench-web.git","ssh_url":"git@github.com:bmarkons/ruby-bench-web.git","clone_url":"https://github.com/bmarkons/ruby-bench-web.git","svn_url":"https://github.com/bmarkons/ruby-bench-web","homepage":"https://rubybench.org","size":4980,"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,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"ruby-bench:master","ref":"master","sha":"92a962f97d76c989da04d5f7da0bb107b8af4909","user":{"login":"ruby-bench","id":6201139,"avatar_url":"https://avatars3.githubusercontent.com/u/6201139?v=3","gravatar_id":"","url":"https://api.github.com/users/ruby-bench","html_url":"https://github.com/ruby-bench","followers_url":"https://api.github.com/users/ruby-bench/followers","following_url":"https://api.github.com/users/ruby-bench/following{/other_user}","gists_url":"https://api.github.com/users/ruby-bench/gists{/gist_id}","starred_url":"https://api.github.com/users/ruby-bench/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ruby-bench/subscriptions","organizations_url":"https://api.github.com/users/ruby-bench/orgs","repos_url":"https://api.github.com/users/ruby-bench/repos","events_url":"https://api.github.com/users/ruby-bench/events{/privacy}","received_events_url":"https://api.github.com/users/ruby-bench/received_events","type":"Organization","site_admin":false},"repo":{"id":26815515,"name":"ruby-bench-web","full_name":"ruby-bench/ruby-bench-web","owner":{"login":"ruby-bench","id":6201139,"avatar_url":"https://avatars3.githubusercontent.com/u/6201139?v=3","gravatar_id":"","url":"https://api.github.com/users/ruby-bench","html_url":"https://github.com/ruby-bench","followers_url":"https://api.github.com/users/ruby-bench/followers","following_url":"https://api.github.com/users/ruby-bench/following{/other_user}","gists_url":"https://api.github.com/users/ruby-bench/gists{/gist_id}","starred_url":"https://api.github.com/users/ruby-bench/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ruby-bench/subscriptions","organizations_url":"https://api.github.com/users/ruby-bench/orgs","repos_url":"https://api.github.com/users/ruby-bench/repos","events_url":"https://api.github.com/users/ruby-bench/events{/privacy}","received_events_url":"https://api.github.com/users/ruby-bench/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ruby-bench/ruby-bench-web","description":"Long Running Ruby Benchmarks","fork":false,"url":"https://api.github.com/repos/ruby-bench/ruby-bench-web","forks_url":"https://api.github.com/repos/ruby-bench/ruby-bench-web/forks","keys_url":"https://api.github.com/repos/ruby-bench/ruby-bench-web/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ruby-bench/ruby-bench-web/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ruby-bench/ruby-bench-web/teams","hooks_url":"https://api.github.com/repos/ruby-bench/ruby-bench-web/hooks","issue_events_url":"https://api.github.com/repos/ruby-bench/ruby-bench-web/issues/events{/number}","events_url":"https://api.github.com/repos/ruby-bench/ruby-bench-web/events","assignees_url":"https://api.github.com/repos/ruby-bench/ruby-bench-web/assignees{/user}","branches_url":"https://api.github.com/repos/ruby-bench/ruby-bench-web/branches{/branch}","tags_url":"https://api.github.com/repos/ruby-bench/ruby-bench-web/tags","blobs_url":"https://api.github.com/repos/ruby-bench/ruby-bench-web/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ruby-bench/ruby-bench-web/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ruby-bench/ruby-bench-web/git/refs{/sha}","trees_url":"https://api.github.com/repos/ruby-bench/ruby-bench-web/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ruby-bench/ruby-bench-web/statuses/{sha}","languages_url":"https://api.github.com/repos/ruby-bench/ruby-bench-web/languages","stargazers_url":"https://api.github.com/repos/ruby-bench/ruby-bench-web/stargazers","contributors_url":"https://api.github.com/repos/ruby-bench/ruby-bench-web/contributors","subscribers_url":"https://api.github.com/repos/ruby-bench/ruby-bench-web/subscribers","subscription_url":"https://api.github.com/repos/ruby-bench/ruby-bench-web/subscription","commits_url":"https://api.github.com/repos/ruby-bench/ruby-bench-web/commits{/sha}","git_commits_url":"https://api.github.com/repos/ruby-bench/ruby-bench-web/git/commits{/sha}","comments_url":"https://api.github.com/repos/ruby-bench/ruby-bench-web/comments{/number}","issue_comment_url":"https://api.github.com/repos/ruby-bench/ruby-bench-web/issues/comments{/number}","contents_url":"https://api.github.com/repos/ruby-bench/ruby-bench-web/contents/{+path}","compare_url":"https://api.github.com/repos/ruby-bench/ruby-bench-web/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ruby-bench/ruby-bench-web/merges","archive_url":"https://api.github.com/repos/ruby-bench/ruby-bench-web/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ruby-bench/ruby-bench-web/downloads","issues_url":"https://api.github.com/repos/ruby-bench/ruby-bench-web/issues{/number}","pulls_url":"https://api.github.com/repos/ruby-bench/ruby-bench-web/pulls{/number}","milestones_url":"https://api.github.com/repos/ruby-bench/ruby-bench-web/milestones{/number}","notifications_url":"https://api.github.com/repos/ruby-bench/ruby-bench-web/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ruby-bench/ruby-bench-web/labels{/name}","releases_url":"https://api.github.com/repos/ruby-bench/ruby-bench-web/releases{/id}","deployments_url":"https://api.github.com/repos/ruby-bench/ruby-bench-web/deployments","created_at":"2014-11-18T15:27:41Z","updated_at":"2017-05-26T10:58:52Z","pushed_at":"2017-06-09T15:19:36Z","git_url":"git://github.com/ruby-bench/ruby-bench-web.git","ssh_url":"git@github.com:ruby-bench/ruby-bench-web.git","clone_url":"https://github.com/ruby-bench/ruby-bench-web.git","svn_url":"https://github.com/ruby-bench/ruby-bench-web","homepage":"https://rubybench.org","size":4959,"stargazers_count":68,"watchers_count":68,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":36,"mirror_url":null,"open_issues_count":8,"forks":36,"open_issues":8,"watchers":68,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ruby-bench/ruby-bench-web/pulls/210"},"html":{"href":"https://github.com/ruby-bench/ruby-bench-web/pull/210"},"issue":{"href":"https://api.github.com/repos/ruby-bench/ruby-bench-web/issues/210"},"comments":{"href":"https://api.github.com/repos/ruby-bench/ruby-bench-web/issues/210/comments"},"review_comments":{"href":"https://api.github.com/repos/ruby-bench/ruby-bench-web/pulls/210/comments"},"review_comment":{"href":"https://api.github.com/repos/ruby-bench/ruby-bench-web/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ruby-bench/ruby-bench-web/pulls/210/commits"},"statuses":{"href":"https://api.github.com/repos/ruby-bench/ruby-bench-web/statuses/b5d54da6d7bd6c7481ffeca06b5ac77d8d29dd63"}}}}
{"actor":{"display_login":"noahgibbs"}}