{"action":"created","comment":{"url":"https://api.github.com/repos/18F/github-dashing/pulls/comments/40100878","id":40100878,"diff_hunk":"@@ -0,0 +1,41 @@\n+require 'dashing'\n+require 'github_backend'\n+require 'webmock/rspec'\n+require 'support/fake_github_api'\n+require 'support/job_helper'\n+include JobHelper\n+\n+describe 'Active Circle CI Repos' do\n+  before do\n+    active_circle_test_setup\n+  end\n+\n+  def job\n+    SCHEDULER.jobs.values.\n+      select { |job| job.block.to_s.include?('active_circle_repos') }.first\n+  end\n+\n+  it 'runs every 24 hours' do\n+    expect(job.schedule_info).to eq '1d'\n+  end\n+\n+  it 'starts after 50 seconds' do\n+    expect(job.next_time).to be_within(1.second).of(50.seconds.from_now)\n+  end\n+\n+  it 'calls CircleBackend.get_last_build_for' do\n+    expect(CircleBackend).\n+      to receive(:get_last_build_for).ordered.with('github-dashing').and_return({})\n+\n+    expect(CircleBackend).\n+      to receive(:get_last_build_for).ordered.with('save-ferris').and_return({})\n+\n+    job.trigger_block\n+  end\n+\n+  it 'sets ACTIVE_CIRCLE_REPOS env var to active repos only' do\n+    job.trigger_block\n+\n+    expect(ENV['ACTIVE_CIRCLE_REPOS']).to eq 'save-ferris'","path":"spec/jobs/active_circle_repos_spec.rb","position":39,"original_position":39,"commit_id":"e7856415b5578b6bca65f02369e1a0d58b8d57b7","original_commit_id":"e7856415b5578b6bca65f02369e1a0d58b8d57b7","user":{"login":"mbland","id":301547,"avatar_url":"https://avatars.githubusercontent.com/u/301547?v=3","gravatar_id":"","url":"https://api.github.com/users/mbland","html_url":"https://github.com/mbland","followers_url":"https://api.github.com/users/mbland/followers","following_url":"https://api.github.com/users/mbland/following{/other_user}","gists_url":"https://api.github.com/users/mbland/gists{/gist_id}","starred_url":"https://api.github.com/users/mbland/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbland/subscriptions","organizations_url":"https://api.github.com/users/mbland/orgs","repos_url":"https://api.github.com/users/mbland/repos","events_url":"https://api.github.com/users/mbland/events{/privacy}","received_events_url":"https://api.github.com/users/mbland/received_events","type":"User","site_admin":false},"body":"Should probably clear this var in the before/after setup.","created_at":"2015-09-22T15:30:00Z","updated_at":"2015-09-22T15:30:00Z","html_url":"https://github.com/18F/github-dashing/pull/26#discussion_r40100878","pull_request_url":"https://api.github.com/repos/18F/github-dashing/pulls/26","_links":{"self":{"href":"https://api.github.com/repos/18F/github-dashing/pulls/comments/40100878"},"html":{"href":"https://github.com/18F/github-dashing/pull/26#discussion_r40100878"},"pull_request":{"href":"https://api.github.com/repos/18F/github-dashing/pulls/26"}}},"pull_request":{"url":"https://api.github.com/repos/18F/github-dashing/pulls/26","id":45592017,"html_url":"https://github.com/18F/github-dashing/pull/26","diff_url":"https://github.com/18F/github-dashing/pull/26.diff","patch_url":"https://github.com/18F/github-dashing/pull/26.patch","issue_url":"https://api.github.com/repos/18F/github-dashing/issues/26","number":26,"state":"open","locked":false,"title":"Add CircleCI build status widget","user":{"login":"monfresh","id":811150,"avatar_url":"https://avatars.githubusercontent.com/u/811150?v=3","gravatar_id":"","url":"https://api.github.com/users/monfresh","html_url":"https://github.com/monfresh","followers_url":"https://api.github.com/users/monfresh/followers","following_url":"https://api.github.com/users/monfresh/following{/other_user}","gists_url":"https://api.github.com/users/monfresh/gists{/gist_id}","starred_url":"https://api.github.com/users/monfresh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monfresh/subscriptions","organizations_url":"https://api.github.com/users/monfresh/orgs","repos_url":"https://api.github.com/users/monfresh/repos","events_url":"https://api.github.com/users/monfresh/events{/privacy}","received_events_url":"https://api.github.com/users/monfresh/received_events","type":"User","site_admin":false},"body":"The Circle CI API does not currently provide a way to get a list of just\r\nthe active repos, so we have to use the GitHub API to get a list of all\r\nrepos that belong to an organization, then make a separate Circle API call for each one (over 300 for 18F), just to determine whether Circle CI has builds for that repo.\r\n\r\nIn order to minimize the amount of times we have to do this, I created a new job that runs once a day and stores this list in an env var, which can then be reused by the Circle CI widget, which runs every 5 minutes.\r\n\r\nI also did the same optimization for the list of GitHub org repos.\r\n\r\nTo support this new optimization, I adjusted the start time of each job so that it would allow enough time to pass for the env vars to get populated.\r\n\r\nCloses #14.","created_at":"2015-09-21T19:56:00Z","updated_at":"2015-09-22T15:30:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b86e8c4b56b9983ec17578334e6a7851cfad1374","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/18F/github-dashing/pulls/26/commits","review_comments_url":"https://api.github.com/repos/18F/github-dashing/pulls/26/comments","review_comment_url":"https://api.github.com/repos/18F/github-dashing/pulls/comments{/number}","comments_url":"https://api.github.com/repos/18F/github-dashing/issues/26/comments","statuses_url":"https://api.github.com/repos/18F/github-dashing/statuses/e7856415b5578b6bca65f02369e1a0d58b8d57b7","head":{"label":"18F:add-circle-ci","ref":"add-circle-ci","sha":"e7856415b5578b6bca65f02369e1a0d58b8d57b7","user":{"login":"18F","id":6233994,"avatar_url":"https://avatars.githubusercontent.com/u/6233994?v=3","gravatar_id":"","url":"https://api.github.com/users/18F","html_url":"https://github.com/18F","followers_url":"https://api.github.com/users/18F/followers","following_url":"https://api.github.com/users/18F/following{/other_user}","gists_url":"https://api.github.com/users/18F/gists{/gist_id}","starred_url":"https://api.github.com/users/18F/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/18F/subscriptions","organizations_url":"https://api.github.com/users/18F/orgs","repos_url":"https://api.github.com/users/18F/repos","events_url":"https://api.github.com/users/18F/events{/privacy}","received_events_url":"https://api.github.com/users/18F/received_events","type":"Organization","site_admin":false},"repo":{"id":35963070,"name":"github-dashing","full_name":"18F/github-dashing","owner":{"login":"18F","id":6233994,"avatar_url":"https://avatars.githubusercontent.com/u/6233994?v=3","gravatar_id":"","url":"https://api.github.com/users/18F","html_url":"https://github.com/18F","followers_url":"https://api.github.com/users/18F/followers","following_url":"https://api.github.com/users/18F/following{/other_user}","gists_url":"https://api.github.com/users/18F/gists{/gist_id}","starred_url":"https://api.github.com/users/18F/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/18F/subscriptions","organizations_url":"https://api.github.com/users/18F/orgs","repos_url":"https://api.github.com/users/18F/repos","events_url":"https://api.github.com/users/18F/events{/privacy}","received_events_url":"https://api.github.com/users/18F/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/18F/github-dashing","description":"Dashboard to monitor the health of github projects based on their contribution statistics, based on the \"Dashing\" framework","fork":true,"url":"https://api.github.com/repos/18F/github-dashing","forks_url":"https://api.github.com/repos/18F/github-dashing/forks","keys_url":"https://api.github.com/repos/18F/github-dashing/keys{/key_id}","collaborators_url":"https://api.github.com/repos/18F/github-dashing/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/18F/github-dashing/teams","hooks_url":"https://api.github.com/repos/18F/github-dashing/hooks","issue_events_url":"https://api.github.com/repos/18F/github-dashing/issues/events{/number}","events_url":"https://api.github.com/repos/18F/github-dashing/events","assignees_url":"https://api.github.com/repos/18F/github-dashing/assignees{/user}","branches_url":"https://api.github.com/repos/18F/github-dashing/branches{/branch}","tags_url":"https://api.github.com/repos/18F/github-dashing/tags","blobs_url":"https://api.github.com/repos/18F/github-dashing/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/18F/github-dashing/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/18F/github-dashing/git/refs{/sha}","trees_url":"https://api.github.com/repos/18F/github-dashing/git/trees{/sha}","statuses_url":"https://api.github.com/repos/18F/github-dashing/statuses/{sha}","languages_url":"https://api.github.com/repos/18F/github-dashing/languages","stargazers_url":"https://api.github.com/repos/18F/github-dashing/stargazers","contributors_url":"https://api.github.com/repos/18F/github-dashing/contributors","subscribers_url":"https://api.github.com/repos/18F/github-dashing/subscribers","subscription_url":"https://api.github.com/repos/18F/github-dashing/subscription","commits_url":"https://api.github.com/repos/18F/github-dashing/commits{/sha}","git_commits_url":"https://api.github.com/repos/18F/github-dashing/git/commits{/sha}","comments_url":"https://api.github.com/repos/18F/github-dashing/comments{/number}","issue_comment_url":"https://api.github.com/repos/18F/github-dashing/issues/comments{/number}","contents_url":"https://api.github.com/repos/18F/github-dashing/contents/{+path}","compare_url":"https://api.github.com/repos/18F/github-dashing/compare/{base}...{head}","merges_url":"https://api.github.com/repos/18F/github-dashing/merges","archive_url":"https://api.github.com/repos/18F/github-dashing/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/18F/github-dashing/downloads","issues_url":"https://api.github.com/repos/18F/github-dashing/issues{/number}","pulls_url":"https://api.github.com/repos/18F/github-dashing/pulls{/number}","milestones_url":"https://api.github.com/repos/18F/github-dashing/milestones{/number}","notifications_url":"https://api.github.com/repos/18F/github-dashing/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/18F/github-dashing/labels{/name}","releases_url":"https://api.github.com/repos/18F/github-dashing/releases{/id}","created_at":"2015-05-20T17:26:57Z","updated_at":"2015-09-17T17:52:32Z","pushed_at":"2015-09-22T02:19:26Z","git_url":"git://github.com/18F/github-dashing.git","ssh_url":"git@github.com:18F/github-dashing.git","clone_url":"https://github.com/18F/github-dashing.git","svn_url":"https://github.com/18F/github-dashing","homepage":"https://project-dashboard.18f.gov/default","size":1680,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":4,"forks":1,"open_issues":4,"watchers":0,"default_branch":"master"}},"base":{"label":"18F:master","ref":"master","sha":"dc9b396a2f0775b50b30eefa8336eef49f46a5f3","user":{"login":"18F","id":6233994,"avatar_url":"https://avatars.githubusercontent.com/u/6233994?v=3","gravatar_id":"","url":"https://api.github.com/users/18F","html_url":"https://github.com/18F","followers_url":"https://api.github.com/users/18F/followers","following_url":"https://api.github.com/users/18F/following{/other_user}","gists_url":"https://api.github.com/users/18F/gists{/gist_id}","starred_url":"https://api.github.com/users/18F/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/18F/subscriptions","organizations_url":"https://api.github.com/users/18F/orgs","repos_url":"https://api.github.com/users/18F/repos","events_url":"https://api.github.com/users/18F/events{/privacy}","received_events_url":"https://api.github.com/users/18F/received_events","type":"Organization","site_admin":false},"repo":{"id":35963070,"name":"github-dashing","full_name":"18F/github-dashing","owner":{"login":"18F","id":6233994,"avatar_url":"https://avatars.githubusercontent.com/u/6233994?v=3","gravatar_id":"","url":"https://api.github.com/users/18F","html_url":"https://github.com/18F","followers_url":"https://api.github.com/users/18F/followers","following_url":"https://api.github.com/users/18F/following{/other_user}","gists_url":"https://api.github.com/users/18F/gists{/gist_id}","starred_url":"https://api.github.com/users/18F/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/18F/subscriptions","organizations_url":"https://api.github.com/users/18F/orgs","repos_url":"https://api.github.com/users/18F/repos","events_url":"https://api.github.com/users/18F/events{/privacy}","received_events_url":"https://api.github.com/users/18F/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/18F/github-dashing","description":"Dashboard to monitor the health of github projects based on their contribution statistics, based on the \"Dashing\" framework","fork":true,"url":"https://api.github.com/repos/18F/github-dashing","forks_url":"https://api.github.com/repos/18F/github-dashing/forks","keys_url":"https://api.github.com/repos/18F/github-dashing/keys{/key_id}","collaborators_url":"https://api.github.com/repos/18F/github-dashing/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/18F/github-dashing/teams","hooks_url":"https://api.github.com/repos/18F/github-dashing/hooks","issue_events_url":"https://api.github.com/repos/18F/github-dashing/issues/events{/number}","events_url":"https://api.github.com/repos/18F/github-dashing/events","assignees_url":"https://api.github.com/repos/18F/github-dashing/assignees{/user}","branches_url":"https://api.github.com/repos/18F/github-dashing/branches{/branch}","tags_url":"https://api.github.com/repos/18F/github-dashing/tags","blobs_url":"https://api.github.com/repos/18F/github-dashing/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/18F/github-dashing/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/18F/github-dashing/git/refs{/sha}","trees_url":"https://api.github.com/repos/18F/github-dashing/git/trees{/sha}","statuses_url":"https://api.github.com/repos/18F/github-dashing/statuses/{sha}","languages_url":"https://api.github.com/repos/18F/github-dashing/languages","stargazers_url":"https://api.github.com/repos/18F/github-dashing/stargazers","contributors_url":"https://api.github.com/repos/18F/github-dashing/contributors","subscribers_url":"https://api.github.com/repos/18F/github-dashing/subscribers","subscription_url":"https://api.github.com/repos/18F/github-dashing/subscription","commits_url":"https://api.github.com/repos/18F/github-dashing/commits{/sha}","git_commits_url":"https://api.github.com/repos/18F/github-dashing/git/commits{/sha}","comments_url":"https://api.github.com/repos/18F/github-dashing/comments{/number}","issue_comment_url":"https://api.github.com/repos/18F/github-dashing/issues/comments{/number}","contents_url":"https://api.github.com/repos/18F/github-dashing/contents/{+path}","compare_url":"https://api.github.com/repos/18F/github-dashing/compare/{base}...{head}","merges_url":"https://api.github.com/repos/18F/github-dashing/merges","archive_url":"https://api.github.com/repos/18F/github-dashing/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/18F/github-dashing/downloads","issues_url":"https://api.github.com/repos/18F/github-dashing/issues{/number}","pulls_url":"https://api.github.com/repos/18F/github-dashing/pulls{/number}","milestones_url":"https://api.github.com/repos/18F/github-dashing/milestones{/number}","notifications_url":"https://api.github.com/repos/18F/github-dashing/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/18F/github-dashing/labels{/name}","releases_url":"https://api.github.com/repos/18F/github-dashing/releases{/id}","created_at":"2015-05-20T17:26:57Z","updated_at":"2015-09-17T17:52:32Z","pushed_at":"2015-09-22T02:19:26Z","git_url":"git://github.com/18F/github-dashing.git","ssh_url":"git@github.com:18F/github-dashing.git","clone_url":"https://github.com/18F/github-dashing.git","svn_url":"https://github.com/18F/github-dashing","homepage":"https://project-dashboard.18f.gov/default","size":1680,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":4,"forks":1,"open_issues":4,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/18F/github-dashing/pulls/26"},"html":{"href":"https://github.com/18F/github-dashing/pull/26"},"issue":{"href":"https://api.github.com/repos/18F/github-dashing/issues/26"},"comments":{"href":"https://api.github.com/repos/18F/github-dashing/issues/26/comments"},"review_comments":{"href":"https://api.github.com/repos/18F/github-dashing/pulls/26/comments"},"review_comment":{"href":"https://api.github.com/repos/18F/github-dashing/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/18F/github-dashing/pulls/26/commits"},"statuses":{"href":"https://api.github.com/repos/18F/github-dashing/statuses/e7856415b5578b6bca65f02369e1a0d58b8d57b7"}}}}