{"action":"created","comment":{"url":"https://api.github.com/repos/ManageIQ/miq_bot/pulls/comments/25388205","id":25388205,"diff_hunk":"@@ -0,0 +1,35 @@\n+class TravisBuildKiller\n+  include Sidekiq::Worker\n+  include Sidetiq::Schedulable\n+  include MiqToolsServices::SidekiqWorkerMixin\n+  sidekiq_options :queue => :miq_bot, :retry => false\n+\n+  recurrence { hourly.minute_of_hour(0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55) }\n+\n+  def perform\n+    if !first_unique_worker?\n+      logger.info \"#{self.class} is already running, skipping\"\n+    else\n+      kill_builds\n+    end\n+  end\n+\n+  private\n+\n+  def kill_builds\n+    repo = CommitMonitorRepo.where(:upstream_user => \"ManageIQ\", :name => \"manageiq\").first\n+    repo.with_travis_service do |travis|\n+      builds_to_cancel = travis.builds\n+        .take_while { |b| b.pending? || b.canceled? }\n+        .reject(&:canceled?)\n+        .group_by(&:pull_request_number)\n+        .flat_map { |_pr_number, builds| builds[1..-1] }","path":"app/workers/travis_build_killer.rb","position":26,"original_position":26,"commit_id":"8224ef379ea963bdc576bfc57969990bcb3ad76e","original_commit_id":"8224ef379ea963bdc576bfc57969990bcb3ad76e","user":{"login":"jrafanie","id":19339,"avatar_url":"https://avatars.githubusercontent.com/u/19339?v=3","gravatar_id":"","url":"https://api.github.com/users/jrafanie","html_url":"https://github.com/jrafanie","followers_url":"https://api.github.com/users/jrafanie/followers","following_url":"https://api.github.com/users/jrafanie/following{/other_user}","gists_url":"https://api.github.com/users/jrafanie/gists{/gist_id}","starred_url":"https://api.github.com/users/jrafanie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jrafanie/subscriptions","organizations_url":"https://api.github.com/users/jrafanie/orgs","repos_url":"https://api.github.com/users/jrafanie/repos","events_url":"https://api.github.com/users/jrafanie/events{/privacy}","received_events_url":"https://api.github.com/users/jrafanie/received_events","type":"User","site_admin":false},"body":":tada: Yay","created_at":"2015-02-25T22:52:15Z","updated_at":"2015-02-25T22:52:15Z","html_url":"https://github.com/ManageIQ/miq_bot/pull/36#discussion_r25388205","pull_request_url":"https://api.github.com/repos/ManageIQ/miq_bot/pulls/36","_links":{"self":{"href":"https://api.github.com/repos/ManageIQ/miq_bot/pulls/comments/25388205"},"html":{"href":"https://github.com/ManageIQ/miq_bot/pull/36#discussion_r25388205"},"pull_request":{"href":"https://api.github.com/repos/ManageIQ/miq_bot/pulls/36"}}},"pull_request":{"url":"https://api.github.com/repos/ManageIQ/miq_bot/pulls/36","id":30027056,"html_url":"https://github.com/ManageIQ/miq_bot/pull/36","diff_url":"https://github.com/ManageIQ/miq_bot/pull/36.diff","patch_url":"https://github.com/ManageIQ/miq_bot/pull/36.patch","issue_url":"https://api.github.com/repos/ManageIQ/miq_bot/issues/36","number":36,"state":"open","locked":false,"title":"Add TravisBuildKiller which kills dup builds for the same PR/branch.","user":{"login":"Fryguy","id":52120,"avatar_url":"https://avatars.githubusercontent.com/u/52120?v=3","gravatar_id":"","url":"https://api.github.com/users/Fryguy","html_url":"https://github.com/Fryguy","followers_url":"https://api.github.com/users/Fryguy/followers","following_url":"https://api.github.com/users/Fryguy/following{/other_user}","gists_url":"https://api.github.com/users/Fryguy/gists{/gist_id}","starred_url":"https://api.github.com/users/Fryguy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Fryguy/subscriptions","organizations_url":"https://api.github.com/users/Fryguy/orgs","repos_url":"https://api.github.com/users/Fryguy/repos","events_url":"https://api.github.com/users/Fryguy/events{/privacy}","received_events_url":"https://api.github.com/users/Fryguy/received_events","type":"User","site_admin":false},"body":"Closes #22","created_at":"2015-02-25T21:28:24Z","updated_at":"2015-02-25T22:52:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"32a34f2e3d6f5a529c0b136a0974d2735c47ff8e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ManageIQ/miq_bot/pulls/36/commits","review_comments_url":"https://api.github.com/repos/ManageIQ/miq_bot/pulls/36/comments","review_comment_url":"https://api.github.com/repos/ManageIQ/miq_bot/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ManageIQ/miq_bot/issues/36/comments","statuses_url":"https://api.github.com/repos/ManageIQ/miq_bot/statuses/8224ef379ea963bdc576bfc57969990bcb3ad76e","head":{"label":"Fryguy:travis_build_killer","ref":"travis_build_killer","sha":"8224ef379ea963bdc576bfc57969990bcb3ad76e","user":{"login":"Fryguy","id":52120,"avatar_url":"https://avatars.githubusercontent.com/u/52120?v=3","gravatar_id":"","url":"https://api.github.com/users/Fryguy","html_url":"https://github.com/Fryguy","followers_url":"https://api.github.com/users/Fryguy/followers","following_url":"https://api.github.com/users/Fryguy/following{/other_user}","gists_url":"https://api.github.com/users/Fryguy/gists{/gist_id}","starred_url":"https://api.github.com/users/Fryguy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Fryguy/subscriptions","organizations_url":"https://api.github.com/users/Fryguy/orgs","repos_url":"https://api.github.com/users/Fryguy/repos","events_url":"https://api.github.com/users/Fryguy/events{/privacy}","received_events_url":"https://api.github.com/users/Fryguy/received_events","type":"User","site_admin":false},"repo":{"id":27161663,"name":"miq_bot","full_name":"Fryguy/miq_bot","owner":{"login":"Fryguy","id":52120,"avatar_url":"https://avatars.githubusercontent.com/u/52120?v=3","gravatar_id":"","url":"https://api.github.com/users/Fryguy","html_url":"https://github.com/Fryguy","followers_url":"https://api.github.com/users/Fryguy/followers","following_url":"https://api.github.com/users/Fryguy/following{/other_user}","gists_url":"https://api.github.com/users/Fryguy/gists{/gist_id}","starred_url":"https://api.github.com/users/Fryguy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Fryguy/subscriptions","organizations_url":"https://api.github.com/users/Fryguy/orgs","repos_url":"https://api.github.com/users/Fryguy/repos","events_url":"https://api.github.com/users/Fryguy/events{/privacy}","received_events_url":"https://api.github.com/users/Fryguy/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Fryguy/miq_bot","description":"ManageIQ Bot","fork":true,"url":"https://api.github.com/repos/Fryguy/miq_bot","forks_url":"https://api.github.com/repos/Fryguy/miq_bot/forks","keys_url":"https://api.github.com/repos/Fryguy/miq_bot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Fryguy/miq_bot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Fryguy/miq_bot/teams","hooks_url":"https://api.github.com/repos/Fryguy/miq_bot/hooks","issue_events_url":"https://api.github.com/repos/Fryguy/miq_bot/issues/events{/number}","events_url":"https://api.github.com/repos/Fryguy/miq_bot/events","assignees_url":"https://api.github.com/repos/Fryguy/miq_bot/assignees{/user}","branches_url":"https://api.github.com/repos/Fryguy/miq_bot/branches{/branch}","tags_url":"https://api.github.com/repos/Fryguy/miq_bot/tags","blobs_url":"https://api.github.com/repos/Fryguy/miq_bot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Fryguy/miq_bot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Fryguy/miq_bot/git/refs{/sha}","trees_url":"https://api.github.com/repos/Fryguy/miq_bot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Fryguy/miq_bot/statuses/{sha}","languages_url":"https://api.github.com/repos/Fryguy/miq_bot/languages","stargazers_url":"https://api.github.com/repos/Fryguy/miq_bot/stargazers","contributors_url":"https://api.github.com/repos/Fryguy/miq_bot/contributors","subscribers_url":"https://api.github.com/repos/Fryguy/miq_bot/subscribers","subscription_url":"https://api.github.com/repos/Fryguy/miq_bot/subscription","commits_url":"https://api.github.com/repos/Fryguy/miq_bot/commits{/sha}","git_commits_url":"https://api.github.com/repos/Fryguy/miq_bot/git/commits{/sha}","comments_url":"https://api.github.com/repos/Fryguy/miq_bot/comments{/number}","issue_comment_url":"https://api.github.com/repos/Fryguy/miq_bot/issues/comments{/number}","contents_url":"https://api.github.com/repos/Fryguy/miq_bot/contents/{+path}","compare_url":"https://api.github.com/repos/Fryguy/miq_bot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Fryguy/miq_bot/merges","archive_url":"https://api.github.com/repos/Fryguy/miq_bot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Fryguy/miq_bot/downloads","issues_url":"https://api.github.com/repos/Fryguy/miq_bot/issues{/number}","pulls_url":"https://api.github.com/repos/Fryguy/miq_bot/pulls{/number}","milestones_url":"https://api.github.com/repos/Fryguy/miq_bot/milestones{/number}","notifications_url":"https://api.github.com/repos/Fryguy/miq_bot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Fryguy/miq_bot/labels{/name}","releases_url":"https://api.github.com/repos/Fryguy/miq_bot/releases{/id}","created_at":"2014-11-26T05:47:47Z","updated_at":"2014-11-26T05:47:47Z","pushed_at":"2015-02-25T21:53:06Z","git_url":"git://github.com/Fryguy/miq_bot.git","ssh_url":"git@github.com:Fryguy/miq_bot.git","clone_url":"https://github.com/Fryguy/miq_bot.git","svn_url":"https://github.com/Fryguy/miq_bot","homepage":null,"size":375,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"ManageIQ:master","ref":"master","sha":"7147695c712af3a79438ca0cdaada7412e37f6dd","user":{"login":"ManageIQ","id":1125575,"avatar_url":"https://avatars.githubusercontent.com/u/1125575?v=3","gravatar_id":"","url":"https://api.github.com/users/ManageIQ","html_url":"https://github.com/ManageIQ","followers_url":"https://api.github.com/users/ManageIQ/followers","following_url":"https://api.github.com/users/ManageIQ/following{/other_user}","gists_url":"https://api.github.com/users/ManageIQ/gists{/gist_id}","starred_url":"https://api.github.com/users/ManageIQ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ManageIQ/subscriptions","organizations_url":"https://api.github.com/users/ManageIQ/orgs","repos_url":"https://api.github.com/users/ManageIQ/repos","events_url":"https://api.github.com/users/ManageIQ/events{/privacy}","received_events_url":"https://api.github.com/users/ManageIQ/received_events","type":"Organization","site_admin":false},"repo":{"id":23851775,"name":"miq_bot","full_name":"ManageIQ/miq_bot","owner":{"login":"ManageIQ","id":1125575,"avatar_url":"https://avatars.githubusercontent.com/u/1125575?v=3","gravatar_id":"","url":"https://api.github.com/users/ManageIQ","html_url":"https://github.com/ManageIQ","followers_url":"https://api.github.com/users/ManageIQ/followers","following_url":"https://api.github.com/users/ManageIQ/following{/other_user}","gists_url":"https://api.github.com/users/ManageIQ/gists{/gist_id}","starred_url":"https://api.github.com/users/ManageIQ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ManageIQ/subscriptions","organizations_url":"https://api.github.com/users/ManageIQ/orgs","repos_url":"https://api.github.com/users/ManageIQ/repos","events_url":"https://api.github.com/users/ManageIQ/events{/privacy}","received_events_url":"https://api.github.com/users/ManageIQ/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ManageIQ/miq_bot","description":"ManageIQ Bot","fork":false,"url":"https://api.github.com/repos/ManageIQ/miq_bot","forks_url":"https://api.github.com/repos/ManageIQ/miq_bot/forks","keys_url":"https://api.github.com/repos/ManageIQ/miq_bot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ManageIQ/miq_bot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ManageIQ/miq_bot/teams","hooks_url":"https://api.github.com/repos/ManageIQ/miq_bot/hooks","issue_events_url":"https://api.github.com/repos/ManageIQ/miq_bot/issues/events{/number}","events_url":"https://api.github.com/repos/ManageIQ/miq_bot/events","assignees_url":"https://api.github.com/repos/ManageIQ/miq_bot/assignees{/user}","branches_url":"https://api.github.com/repos/ManageIQ/miq_bot/branches{/branch}","tags_url":"https://api.github.com/repos/ManageIQ/miq_bot/tags","blobs_url":"https://api.github.com/repos/ManageIQ/miq_bot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ManageIQ/miq_bot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ManageIQ/miq_bot/git/refs{/sha}","trees_url":"https://api.github.com/repos/ManageIQ/miq_bot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ManageIQ/miq_bot/statuses/{sha}","languages_url":"https://api.github.com/repos/ManageIQ/miq_bot/languages","stargazers_url":"https://api.github.com/repos/ManageIQ/miq_bot/stargazers","contributors_url":"https://api.github.com/repos/ManageIQ/miq_bot/contributors","subscribers_url":"https://api.github.com/repos/ManageIQ/miq_bot/subscribers","subscription_url":"https://api.github.com/repos/ManageIQ/miq_bot/subscription","commits_url":"https://api.github.com/repos/ManageIQ/miq_bot/commits{/sha}","git_commits_url":"https://api.github.com/repos/ManageIQ/miq_bot/git/commits{/sha}","comments_url":"https://api.github.com/repos/ManageIQ/miq_bot/comments{/number}","issue_comment_url":"https://api.github.com/repos/ManageIQ/miq_bot/issues/comments{/number}","contents_url":"https://api.github.com/repos/ManageIQ/miq_bot/contents/{+path}","compare_url":"https://api.github.com/repos/ManageIQ/miq_bot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ManageIQ/miq_bot/merges","archive_url":"https://api.github.com/repos/ManageIQ/miq_bot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ManageIQ/miq_bot/downloads","issues_url":"https://api.github.com/repos/ManageIQ/miq_bot/issues{/number}","pulls_url":"https://api.github.com/repos/ManageIQ/miq_bot/pulls{/number}","milestones_url":"https://api.github.com/repos/ManageIQ/miq_bot/milestones{/number}","notifications_url":"https://api.github.com/repos/ManageIQ/miq_bot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ManageIQ/miq_bot/labels{/name}","releases_url":"https://api.github.com/repos/ManageIQ/miq_bot/releases{/id}","created_at":"2014-09-09T22:02:14Z","updated_at":"2015-02-11T19:57:27Z","pushed_at":"2015-02-11T19:57:26Z","git_url":"git://github.com/ManageIQ/miq_bot.git","ssh_url":"git@github.com:ManageIQ/miq_bot.git","clone_url":"https://github.com/ManageIQ/miq_bot.git","svn_url":"https://github.com/ManageIQ/miq_bot","homepage":null,"size":478,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":22,"forks":2,"open_issues":22,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ManageIQ/miq_bot/pulls/36"},"html":{"href":"https://github.com/ManageIQ/miq_bot/pull/36"},"issue":{"href":"https://api.github.com/repos/ManageIQ/miq_bot/issues/36"},"comments":{"href":"https://api.github.com/repos/ManageIQ/miq_bot/issues/36/comments"},"review_comments":{"href":"https://api.github.com/repos/ManageIQ/miq_bot/pulls/36/comments"},"review_comment":{"href":"https://api.github.com/repos/ManageIQ/miq_bot/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ManageIQ/miq_bot/pulls/36/commits"},"statuses":{"href":"https://api.github.com/repos/ManageIQ/miq_bot/statuses/8224ef379ea963bdc576bfc57969990bcb3ad76e"}}}}