GitHub PullRequestReviewCommentEvent at 2014-08-05 05:13:56
Repository: flapjack
Actor: jessereynolds
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/flapjack/flapjack/pulls/comments/15795411","id":15795411,"diff_hunk":"@@ -132,6 +134,130 @@ def self.conflate_to_keys(entity_checks_hash)\n         result\n       end\n \n+      def self.find_maintenance(options = {})\n+        raise \"Redis connection not set\" unless redis = options[:redis]\n+        d = []\n+        type = options[:type]\n+        keys = redis.keys(\"*:#{type}_maintenances\")\n+        keys.each do |k|\n+          entity = k.split(':')[0]\n+          check = k.split(':')[1]\n+          ec = Flapjack::Data::EntityCheck.for_entity_name(entity, check, :redis => redis)\n+          # Only return entries where the state matches the one passed in\n+          next unless options[:state].nil? || options[:state] != ec.state\n+          windows = ec.maintenances(nil, nil, type.to_sym => true)\n+          windows.each do |window|\n+            entry = { :entity => entity,\n+                      :check => check,\n+                      :state => ec.state\n+            }\n+            # Only return entries where the summary matches the reason passed in, or the reason isn't set\n+            next unless options[:reason].nil? || Regexp.new(options[:reason]).match(window[:summary])\n+            next unless options[:entity].nil? || Regexp.new(options[:entity]).match(entity)\n+            next unless options[:check].nil? || Regexp.new(options[:check]).match(check)\n+            # Only return entries where the maintenance start and end times are in the bounds of the input\n+            d.push(entry.merge!(window)) if check_timestamp(options[:started], window[:start_time]) && check_timestamp(options[:finishing], window[:end_time]) && check_interval(options[:duration], window[:duration])\n+          end\n+        end\n+        d\n+      end\n+\n+      def self.delete_maintenance(options = {})\n+        raise \"Redis connection not set\" unless redis = options[:redis]\n+        entries = find_maintenance(options)\n+        # Try to delete all entries passed in, but return false if any entries failed\n+        success = true\n+        entries.each do |entry|\n+          if entry[:end_time] < Time.now.to_i\n+            puts \"Entry can't be deleted as it finished in the past: #{entry}\"","path":"lib/flapjack/data/entity_check.rb","position":48,"original_position":48,"commit_id":"9d6e4c0f8436e46716c7de9a348b0c2177bcb225","original_commit_id":"9d6e4c0f8436e46716c7de9a348b0c2177bcb225","user":{"login":"jessereynolds","id":391439,"avatar_url":"https://avatars.githubusercontent.com/u/391439?v=2","gravatar_id":"ae0689a4447971bf0515180c6232366f","url":"https://api.github.com/users/jessereynolds","html_url":"https://github.com/jessereynolds","followers_url":"https://api.github.com/users/jessereynolds/followers","following_url":"https://api.github.com/users/jessereynolds/following{/other_user}","gists_url":"https://api.github.com/users/jessereynolds/gists{/gist_id}","starred_url":"https://api.github.com/users/jessereynolds/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jessereynolds/subscriptions","organizations_url":"https://api.github.com/users/jessereynolds/orgs","repos_url":"https://api.github.com/users/jessereynolds/repos","events_url":"https://api.github.com/users/jessereynolds/events{/privacy}","received_events_url":"https://api.github.com/users/jessereynolds/received_events","type":"User","site_admin":false},"body":"pick up :logger  from options and use that eg \r\n```ruby\r\nlogger.warn(\"Maintenance can't be deleted as it finished in the past: #{entry}\")\r\n```\r\nor return error messages to the calling method perhaps, so you can surface in a way appropriate for the execution context (cli in this case, but exposing this via the api would be useful, and an api caller may want to see a list of the maintenances unable to be deleted?) ","created_at":"2014-08-05T05:13:56Z","updated_at":"2014-08-05T05:13:56Z","html_url":"https://github.com/flapjack/flapjack/pull/597#discussion_r15795411","pull_request_url":"https://api.github.com/repos/flapjack/flapjack/pulls/597","_links":{"self":{"href":"https://api.github.com/repos/flapjack/flapjack/pulls/comments/15795411"},"html":{"href":"https://github.com/flapjack/flapjack/pull/597#discussion_r15795411"},"pull_request":{"href":"https://api.github.com/repos/flapjack/flapjack/pulls/597"}}},"pull_request":{"url":"https://api.github.com/repos/flapjack/flapjack/pulls/597","id":19321505,"html_url":"https://github.com/flapjack/flapjack/pull/597","diff_url":"https://github.com/flapjack/flapjack/pull/597.diff","patch_url":"https://github.com/flapjack/flapjack/pull/597.patch","issue_url":"https://api.github.com/repos/flapjack/flapjack/issues/597","number":597,"state":"open","title":"Add maintenance to the CLI (closes #562, #563)","user":{"login":"Hobbsee","id":3038925,"avatar_url":"https://avatars.githubusercontent.com/u/3038925?v=2","gravatar_id":"22af999dc97a139c1e515b0ccb9ee993","url":"https://api.github.com/users/Hobbsee","html_url":"https://github.com/Hobbsee","followers_url":"https://api.github.com/users/Hobbsee/followers","following_url":"https://api.github.com/users/Hobbsee/following{/other_user}","gists_url":"https://api.github.com/users/Hobbsee/gists{/gist_id}","starred_url":"https://api.github.com/users/Hobbsee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Hobbsee/subscriptions","organizations_url":"https://api.github.com/users/Hobbsee/orgs","repos_url":"https://api.github.com/users/Hobbsee/repos","events_url":"https://api.github.com/users/Hobbsee/events{/privacy}","received_events_url":"https://api.github.com/users/Hobbsee/received_events","type":"User","site_admin":false},"body":"As part of this, I've also:\r\n\r\n- Updated create_*scheduled_maintenance to allow for an input string to be parsed by Chronic.  This has no effect on existing code.\r\n- Fixed end_unscheduled_maintenance to return a boolean when the unscheduled maintenance is ended (Also done in #596)\r\n- Moved the times in the tests to global variables\r\n- Had rubocop fix indenting/spacing on tests","created_at":"2014-08-05T04:03:51Z","updated_at":"2014-08-05T05:13:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a3d98fc2c6330ee1c2bddf0f8532adbfd96ff20f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/flapjack/flapjack/pulls/597/commits","review_comments_url":"https://api.github.com/repos/flapjack/flapjack/pulls/597/comments","review_comment_url":"https://api.github.com/repos/flapjack/flapjack/pulls/comments/{number}","comments_url":"https://api.github.com/repos/flapjack/flapjack/issues/597/comments","statuses_url":"https://api.github.com/repos/flapjack/flapjack/statuses/9d6e4c0f8436e46716c7de9a348b0c2177bcb225","head":{"label":"flapjack:feature/maintenance","ref":"feature/maintenance","sha":"9d6e4c0f8436e46716c7de9a348b0c2177bcb225","user":{"login":"flapjack","id":2343953,"avatar_url":"https://avatars.githubusercontent.com/u/2343953?v=2","gravatar_id":"c49b8ba436c628f552e9cb9b768b18e8","url":"https://api.github.com/users/flapjack","html_url":"https://github.com/flapjack","followers_url":"https://api.github.com/users/flapjack/followers","following_url":"https://api.github.com/users/flapjack/following{/other_user}","gists_url":"https://api.github.com/users/flapjack/gists{/gist_id}","starred_url":"https://api.github.com/users/flapjack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flapjack/subscriptions","organizations_url":"https://api.github.com/users/flapjack/orgs","repos_url":"https://api.github.com/users/flapjack/repos","events_url":"https://api.github.com/users/flapjack/events{/privacy}","received_events_url":"https://api.github.com/users/flapjack/received_events","type":"Organization","site_admin":false},"repo":{"id":145744,"name":"flapjack","full_name":"flapjack/flapjack","owner":{"login":"flapjack","id":2343953,"avatar_url":"https://avatars.githubusercontent.com/u/2343953?v=2","gravatar_id":"c49b8ba436c628f552e9cb9b768b18e8","url":"https://api.github.com/users/flapjack","html_url":"https://github.com/flapjack","followers_url":"https://api.github.com/users/flapjack/followers","following_url":"https://api.github.com/users/flapjack/following{/other_user}","gists_url":"https://api.github.com/users/flapjack/gists{/gist_id}","starred_url":"https://api.github.com/users/flapjack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flapjack/subscriptions","organizations_url":"https://api.github.com/users/flapjack/orgs","repos_url":"https://api.github.com/users/flapjack/repos","events_url":"https://api.github.com/users/flapjack/events{/privacy}","received_events_url":"https://api.github.com/users/flapjack/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/flapjack/flapjack","description":"Monitoring notification routing + event processing system","fork":false,"url":"https://api.github.com/repos/flapjack/flapjack","forks_url":"https://api.github.com/repos/flapjack/flapjack/forks","keys_url":"https://api.github.com/repos/flapjack/flapjack/keys{/key_id}","collaborators_url":"https://api.github.com/repos/flapjack/flapjack/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/flapjack/flapjack/teams","hooks_url":"https://api.github.com/repos/flapjack/flapjack/hooks","issue_events_url":"https://api.github.com/repos/flapjack/flapjack/issues/events{/number}","events_url":"https://api.github.com/repos/flapjack/flapjack/events","assignees_url":"https://api.github.com/repos/flapjack/flapjack/assignees{/user}","branches_url":"https://api.github.com/repos/flapjack/flapjack/branches{/branch}","tags_url":"https://api.github.com/repos/flapjack/flapjack/tags","blobs_url":"https://api.github.com/repos/flapjack/flapjack/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/flapjack/flapjack/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/flapjack/flapjack/git/refs{/sha}","trees_url":"https://api.github.com/repos/flapjack/flapjack/git/trees{/sha}","statuses_url":"https://api.github.com/repos/flapjack/flapjack/statuses/{sha}","languages_url":"https://api.github.com/repos/flapjack/flapjack/languages","stargazers_url":"https://api.github.com/repos/flapjack/flapjack/stargazers","contributors_url":"https://api.github.com/repos/flapjack/flapjack/contributors","subscribers_url":"https://api.github.com/repos/flapjack/flapjack/subscribers","subscription_url":"https://api.github.com/repos/flapjack/flapjack/subscription","commits_url":"https://api.github.com/repos/flapjack/flapjack/commits{/sha}","git_commits_url":"https://api.github.com/repos/flapjack/flapjack/git/commits{/sha}","comments_url":"https://api.github.com/repos/flapjack/flapjack/comments{/number}","issue_comment_url":"https://api.github.com/repos/flapjack/flapjack/issues/comments/{number}","contents_url":"https://api.github.com/repos/flapjack/flapjack/contents/{+path}","compare_url":"https://api.github.com/repos/flapjack/flapjack/compare/{base}...{head}","merges_url":"https://api.github.com/repos/flapjack/flapjack/merges","archive_url":"https://api.github.com/repos/flapjack/flapjack/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/flapjack/flapjack/downloads","issues_url":"https://api.github.com/repos/flapjack/flapjack/issues{/number}","pulls_url":"https://api.github.com/repos/flapjack/flapjack/pulls{/number}","milestones_url":"https://api.github.com/repos/flapjack/flapjack/milestones{/number}","notifications_url":"https://api.github.com/repos/flapjack/flapjack/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/flapjack/flapjack/labels{/name}","releases_url":"https://api.github.com/repos/flapjack/flapjack/releases{/id}","created_at":"2009-03-08T11:47:49Z","updated_at":"2014-08-03T16:09:19Z","pushed_at":"2014-08-05T03:59:15Z","git_url":"git://github.com/flapjack/flapjack.git","ssh_url":"git@github.com:flapjack/flapjack.git","clone_url":"https://github.com/flapjack/flapjack.git","svn_url":"https://github.com/flapjack/flapjack","homepage":"flapjack.io","size":24318,"stargazers_count":340,"watchers_count":340,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":45,"mirror_url":null,"open_issues_count":106,"forks":45,"open_issues":106,"watchers":340,"default_branch":"master"}},"base":{"label":"flapjack:master","ref":"master","sha":"7b83eab2afeca6aff25c48e4b37309fadd04d07b","user":{"login":"flapjack","id":2343953,"avatar_url":"https://avatars.githubusercontent.com/u/2343953?v=2","gravatar_id":"c49b8ba436c628f552e9cb9b768b18e8","url":"https://api.github.com/users/flapjack","html_url":"https://github.com/flapjack","followers_url":"https://api.github.com/users/flapjack/followers","following_url":"https://api.github.com/users/flapjack/following{/other_user}","gists_url":"https://api.github.com/users/flapjack/gists{/gist_id}","starred_url":"https://api.github.com/users/flapjack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flapjack/subscriptions","organizations_url":"https://api.github.com/users/flapjack/orgs","repos_url":"https://api.github.com/users/flapjack/repos","events_url":"https://api.github.com/users/flapjack/events{/privacy}","received_events_url":"https://api.github.com/users/flapjack/received_events","type":"Organization","site_admin":false},"repo":{"id":145744,"name":"flapjack","full_name":"flapjack/flapjack","owner":{"login":"flapjack","id":2343953,"avatar_url":"https://avatars.githubusercontent.com/u/2343953?v=2","gravatar_id":"c49b8ba436c628f552e9cb9b768b18e8","url":"https://api.github.com/users/flapjack","html_url":"https://github.com/flapjack","followers_url":"https://api.github.com/users/flapjack/followers","following_url":"https://api.github.com/users/flapjack/following{/other_user}","gists_url":"https://api.github.com/users/flapjack/gists{/gist_id}","starred_url":"https://api.github.com/users/flapjack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flapjack/subscriptions","organizations_url":"https://api.github.com/users/flapjack/orgs","repos_url":"https://api.github.com/users/flapjack/repos","events_url":"https://api.github.com/users/flapjack/events{/privacy}","received_events_url":"https://api.github.com/users/flapjack/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/flapjack/flapjack","description":"Monitoring notification routing + event processing system","fork":false,"url":"https://api.github.com/repos/flapjack/flapjack","forks_url":"https://api.github.com/repos/flapjack/flapjack/forks","keys_url":"https://api.github.com/repos/flapjack/flapjack/keys{/key_id}","collaborators_url":"https://api.github.com/repos/flapjack/flapjack/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/flapjack/flapjack/teams","hooks_url":"https://api.github.com/repos/flapjack/flapjack/hooks","issue_events_url":"https://api.github.com/repos/flapjack/flapjack/issues/events{/number}","events_url":"https://api.github.com/repos/flapjack/flapjack/events","assignees_url":"https://api.github.com/repos/flapjack/flapjack/assignees{/user}","branches_url":"https://api.github.com/repos/flapjack/flapjack/branches{/branch}","tags_url":"https://api.github.com/repos/flapjack/flapjack/tags","blobs_url":"https://api.github.com/repos/flapjack/flapjack/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/flapjack/flapjack/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/flapjack/flapjack/git/refs{/sha}","trees_url":"https://api.github.com/repos/flapjack/flapjack/git/trees{/sha}","statuses_url":"https://api.github.com/repos/flapjack/flapjack/statuses/{sha}","languages_url":"https://api.github.com/repos/flapjack/flapjack/languages","stargazers_url":"https://api.github.com/repos/flapjack/flapjack/stargazers","contributors_url":"https://api.github.com/repos/flapjack/flapjack/contributors","subscribers_url":"https://api.github.com/repos/flapjack/flapjack/subscribers","subscription_url":"https://api.github.com/repos/flapjack/flapjack/subscription","commits_url":"https://api.github.com/repos/flapjack/flapjack/commits{/sha}","git_commits_url":"https://api.github.com/repos/flapjack/flapjack/git/commits{/sha}","comments_url":"https://api.github.com/repos/flapjack/flapjack/comments{/number}","issue_comment_url":"https://api.github.com/repos/flapjack/flapjack/issues/comments/{number}","contents_url":"https://api.github.com/repos/flapjack/flapjack/contents/{+path}","compare_url":"https://api.github.com/repos/flapjack/flapjack/compare/{base}...{head}","merges_url":"https://api.github.com/repos/flapjack/flapjack/merges","archive_url":"https://api.github.com/repos/flapjack/flapjack/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/flapjack/flapjack/downloads","issues_url":"https://api.github.com/repos/flapjack/flapjack/issues{/number}","pulls_url":"https://api.github.com/repos/flapjack/flapjack/pulls{/number}","milestones_url":"https://api.github.com/repos/flapjack/flapjack/milestones{/number}","notifications_url":"https://api.github.com/repos/flapjack/flapjack/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/flapjack/flapjack/labels{/name}","releases_url":"https://api.github.com/repos/flapjack/flapjack/releases{/id}","created_at":"2009-03-08T11:47:49Z","updated_at":"2014-08-03T16:09:19Z","pushed_at":"2014-08-05T03:59:15Z","git_url":"git://github.com/flapjack/flapjack.git","ssh_url":"git@github.com:flapjack/flapjack.git","clone_url":"https://github.com/flapjack/flapjack.git","svn_url":"https://github.com/flapjack/flapjack","homepage":"flapjack.io","size":24318,"stargazers_count":340,"watchers_count":340,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":45,"mirror_url":null,"open_issues_count":106,"forks":45,"open_issues":106,"watchers":340,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/flapjack/flapjack/pulls/597"},"html":{"href":"https://github.com/flapjack/flapjack/pull/597"},"issue":{"href":"https://api.github.com/repos/flapjack/flapjack/issues/597"},"comments":{"href":"https://api.github.com/repos/flapjack/flapjack/issues/597/comments"},"review_comments":{"href":"https://api.github.com/repos/flapjack/flapjack/pulls/597/comments"},"review_comment":{"href":"https://api.github.com/repos/flapjack/flapjack/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/flapjack/flapjack/pulls/597/commits"},"statuses":{"href":"https://api.github.com/repos/flapjack/flapjack/statuses/9d6e4c0f8436e46716c7de9a348b0c2177bcb225"}}}}