{"action":"created","comment":{"url":"https://api.github.com/repos/heroku/retrodot/pulls/comments/79879813","id":79879813,"diff_hunk":"@@ -1,3 +1,77 @@\n-class StartIncidentCommand < ChatOpsCommand\n-  match /start( an)? incident/\n+module ChatOps::Commands\n+  class StartIncidentCommand < ChatOpsCommand\n+    match %r{\n+            # allow \"start incident\" or \"start an incident\"\n+            start\\s+(an\\s+)?incident\n+            (\\s+\n+              (\n+                # if they specify an incident ID, use that.\n+                (?<incident_id>\\d+)\n+\n+                # incident ID must be followed by whitespace or EOL\n+                (\\s+|$)\n+\n+                # Don't match incident #14 in \"start an incident 14 minutes ago\"\n+                (?!(seconds|minutes|hours)\\s+ago)\n+\n+              )?\n+\n+              # Slurp up the remainder.  IncidentResponse.parse_timestamp will\n+              # parse it as a timestamp specified in natural language.\n+              (?<timestamp>.*)\n+            )?\n+            $\n+          }ix\n+\n+    help_message \"h start incident [#] [at <timespec>] - sets or overwrites incident start time (timespec examples: 5 minutes ago, 3pm, etc)\"\n+\n+    def run(user, match)\n+      incident_id = infer_incident_id(match[:incident_id])\n+      chat_start = get_chat_start(match[:timestamp]).in_time_zone(Config.time_zone)\n+\n+      message = [\"Recorded the start of chat for incident \\##{incident_id} at #{chat_start.inspect}\"]\n+\n+      incident = Incident.find_or_create_by(incident_id: incident_id)\n+\n+      if incident.chat_start\n+        message << \"     (overwriting start time for incident \\##{incident_id}, was: #{incident.chat_start.inspect})\"\n+      end\n+\n+      incident.timeline_start = Time.now\n+      incident.chat_start = get_chat_start(match[:timestamp])\n+      incident.responders << user\n+      incident.save\n+\n+      ChatOps.help.each_line do |line|\n+        message << \"  \" + line\n+      end\n+\n+      { message: message.join(\"\\n\") }\n+    end","path":"lib/chat_ops/commands/start_incident_command.rb","position":52,"original_position":52,"commit_id":"76fe325c0419dbbbef64fe67fb4a4dcc813396c8","original_commit_id":"76fe325c0419dbbbef64fe67fb4a4dcc813396c8","user":{"login":"reidmix","id":12073,"avatar_url":"https://avatars.githubusercontent.com/u/12073?v=3","gravatar_id":"","url":"https://api.github.com/users/reidmix","html_url":"https://github.com/reidmix","followers_url":"https://api.github.com/users/reidmix/followers","following_url":"https://api.github.com/users/reidmix/following{/other_user}","gists_url":"https://api.github.com/users/reidmix/gists{/gist_id}","starred_url":"https://api.github.com/users/reidmix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reidmix/subscriptions","organizations_url":"https://api.github.com/users/reidmix/orgs","repos_url":"https://api.github.com/users/reidmix/repos","events_url":"https://api.github.com/users/reidmix/events{/privacy}","received_events_url":"https://api.github.com/users/reidmix/received_events","type":"User","site_admin":false},"body":"I know that I'm reviewing this at towards the end and not the beginning where this would have been more useful. This is a suggestion, and probably one that you can save until after MVP when you can do a refactor .\r\n\r\nAssuming this all makes sense, I can talk you through my thinking if not.","created_at":"2016-09-21T16:49:09Z","updated_at":"2016-09-21T16:49:09Z","html_url":"https://github.com/heroku/retrodot/pull/44#discussion_r79879813","pull_request_url":"https://api.github.com/repos/heroku/retrodot/pulls/44","_links":{"self":{"href":"https://api.github.com/repos/heroku/retrodot/pulls/comments/79879813"},"html":{"href":"https://github.com/heroku/retrodot/pull/44#discussion_r79879813"},"pull_request":{"href":"https://api.github.com/repos/heroku/retrodot/pulls/44"}}},"pull_request":{"url":"https://api.github.com/repos/heroku/retrodot/pulls/44","id":84363176,"html_url":"https://github.com/heroku/retrodot/pull/44","diff_url":"https://github.com/heroku/retrodot/pull/44.diff","patch_url":"https://github.com/heroku/retrodot/pull/44.patch","issue_url":"https://api.github.com/repos/heroku/retrodot/issues/44","number":44,"state":"closed","locked":false,"title":"\"start incident\" command","user":{"login":"lexelby","id":4446653,"avatar_url":"https://avatars.githubusercontent.com/u/4446653?v=3","gravatar_id":"","url":"https://api.github.com/users/lexelby","html_url":"https://github.com/lexelby","followers_url":"https://api.github.com/users/lexelby/followers","following_url":"https://api.github.com/users/lexelby/following{/other_user}","gists_url":"https://api.github.com/users/lexelby/gists{/gist_id}","starred_url":"https://api.github.com/users/lexelby/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lexelby/subscriptions","organizations_url":"https://api.github.com/users/lexelby/orgs","repos_url":"https://api.github.com/users/lexelby/repos","events_url":"https://api.github.com/users/lexelby/events{/privacy}","received_events_url":"https://api.github.com/users/lexelby/received_events","type":"User","site_admin":false},"body":"Posting a WIP because folks were curious about my time zone woes.\r\n\r\nThe highlight reel:\r\n\r\n* The old chatops stuff could handle '15:12 EDT', for example, along with natural language like \"15 minutes ago\".\r\n* Ruby's canonical gem for natural language date parsing is Chronic.\r\n* Chronic pukes on \"15:12 EDT\" and returns `nil`.\r\n* I assumed this was because it couldn't parse time zones.\r\n* I spent a very very long time trying to figure out how to parse \"EDT\", \"PDT\", \"PST\", etc in rails.\r\n  * Spoiler: it's really difficult.  Indiana makes life very difficult.\r\n* Turns out that Chronic only hates time zones [sometimes](https://github.com/mojombo/chronic/issues/134), so there's a relatively simple workaround.\r\n* denouement: I can never remember if it's \"EDT\" or \"EST\" at any given time of the year, so I made the code pick the correct one no matter which the user says.\r\n\r\ncc @jmervine @reidmix","created_at":"2016-09-07T19:58:57Z","updated_at":"2016-09-21T16:49:09Z","closed_at":"2016-09-14T15:44:49Z","merged_at":"2016-09-14T15:44:49Z","merge_commit_sha":"1d03322d39a13c9c534de3bab78b9c3ba0745225","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/heroku/retrodot/pulls/44/commits","review_comments_url":"https://api.github.com/repos/heroku/retrodot/pulls/44/comments","review_comment_url":"https://api.github.com/repos/heroku/retrodot/pulls/comments{/number}","comments_url":"https://api.github.com/repos/heroku/retrodot/issues/44/comments","statuses_url":"https://api.github.com/repos/heroku/retrodot/statuses/76fe325c0419dbbbef64fe67fb4a4dcc813396c8","head":{"label":"heroku:chatops-commands","ref":"chatops-commands","sha":"76fe325c0419dbbbef64fe67fb4a4dcc813396c8","user":{"login":"heroku","id":23211,"avatar_url":"https://avatars.githubusercontent.com/u/23211?v=3","gravatar_id":"","url":"https://api.github.com/users/heroku","html_url":"https://github.com/heroku","followers_url":"https://api.github.com/users/heroku/followers","following_url":"https://api.github.com/users/heroku/following{/other_user}","gists_url":"https://api.github.com/users/heroku/gists{/gist_id}","starred_url":"https://api.github.com/users/heroku/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/heroku/subscriptions","organizations_url":"https://api.github.com/users/heroku/orgs","repos_url":"https://api.github.com/users/heroku/repos","events_url":"https://api.github.com/users/heroku/events{/privacy}","received_events_url":"https://api.github.com/users/heroku/received_events","type":"Organization","site_admin":false},"repo":{"id":64845715,"name":"retrodot","full_name":"heroku/retrodot","owner":{"login":"heroku","id":23211,"avatar_url":"https://avatars.githubusercontent.com/u/23211?v=3","gravatar_id":"","url":"https://api.github.com/users/heroku","html_url":"https://github.com/heroku","followers_url":"https://api.github.com/users/heroku/followers","following_url":"https://api.github.com/users/heroku/following{/other_user}","gists_url":"https://api.github.com/users/heroku/gists{/gist_id}","starred_url":"https://api.github.com/users/heroku/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/heroku/subscriptions","organizations_url":"https://api.github.com/users/heroku/orgs","repos_url":"https://api.github.com/users/heroku/repos","events_url":"https://api.github.com/users/heroku/events{/privacy}","received_events_url":"https://api.github.com/users/heroku/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/heroku/retrodot","description":"A self-service tool to automate the facilitation, collection and system of record for the retrospective process","fork":false,"url":"https://api.github.com/repos/heroku/retrodot","forks_url":"https://api.github.com/repos/heroku/retrodot/forks","keys_url":"https://api.github.com/repos/heroku/retrodot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/heroku/retrodot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/heroku/retrodot/teams","hooks_url":"https://api.github.com/repos/heroku/retrodot/hooks","issue_events_url":"https://api.github.com/repos/heroku/retrodot/issues/events{/number}","events_url":"https://api.github.com/repos/heroku/retrodot/events","assignees_url":"https://api.github.com/repos/heroku/retrodot/assignees{/user}","branches_url":"https://api.github.com/repos/heroku/retrodot/branches{/branch}","tags_url":"https://api.github.com/repos/heroku/retrodot/tags","blobs_url":"https://api.github.com/repos/heroku/retrodot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/heroku/retrodot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/heroku/retrodot/git/refs{/sha}","trees_url":"https://api.github.com/repos/heroku/retrodot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/heroku/retrodot/statuses/{sha}","languages_url":"https://api.github.com/repos/heroku/retrodot/languages","stargazers_url":"https://api.github.com/repos/heroku/retrodot/stargazers","contributors_url":"https://api.github.com/repos/heroku/retrodot/contributors","subscribers_url":"https://api.github.com/repos/heroku/retrodot/subscribers","subscription_url":"https://api.github.com/repos/heroku/retrodot/subscription","commits_url":"https://api.github.com/repos/heroku/retrodot/commits{/sha}","git_commits_url":"https://api.github.com/repos/heroku/retrodot/git/commits{/sha}","comments_url":"https://api.github.com/repos/heroku/retrodot/comments{/number}","issue_comment_url":"https://api.github.com/repos/heroku/retrodot/issues/comments{/number}","contents_url":"https://api.github.com/repos/heroku/retrodot/contents/{+path}","compare_url":"https://api.github.com/repos/heroku/retrodot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/heroku/retrodot/merges","archive_url":"https://api.github.com/repos/heroku/retrodot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/heroku/retrodot/downloads","issues_url":"https://api.github.com/repos/heroku/retrodot/issues{/number}","pulls_url":"https://api.github.com/repos/heroku/retrodot/pulls{/number}","milestones_url":"https://api.github.com/repos/heroku/retrodot/milestones{/number}","notifications_url":"https://api.github.com/repos/heroku/retrodot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/heroku/retrodot/labels{/name}","releases_url":"https://api.github.com/repos/heroku/retrodot/releases{/id}","deployments_url":"https://api.github.com/repos/heroku/retrodot/deployments","created_at":"2016-08-03T12:51:55Z","updated_at":"2016-09-01T14:23:25Z","pushed_at":"2016-09-20T21:04:30Z","git_url":"git://github.com/heroku/retrodot.git","ssh_url":"git@github.com:heroku/retrodot.git","clone_url":"https://github.com/heroku/retrodot.git","svn_url":"https://github.com/heroku/retrodot","homepage":null,"size":300,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":0,"forks":2,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"heroku:master","ref":"master","sha":"1b6b5f5116c3cda526dfdbbf2088a8ef1763a08c","user":{"login":"heroku","id":23211,"avatar_url":"https://avatars.githubusercontent.com/u/23211?v=3","gravatar_id":"","url":"https://api.github.com/users/heroku","html_url":"https://github.com/heroku","followers_url":"https://api.github.com/users/heroku/followers","following_url":"https://api.github.com/users/heroku/following{/other_user}","gists_url":"https://api.github.com/users/heroku/gists{/gist_id}","starred_url":"https://api.github.com/users/heroku/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/heroku/subscriptions","organizations_url":"https://api.github.com/users/heroku/orgs","repos_url":"https://api.github.com/users/heroku/repos","events_url":"https://api.github.com/users/heroku/events{/privacy}","received_events_url":"https://api.github.com/users/heroku/received_events","type":"Organization","site_admin":false},"repo":{"id":64845715,"name":"retrodot","full_name":"heroku/retrodot","owner":{"login":"heroku","id":23211,"avatar_url":"https://avatars.githubusercontent.com/u/23211?v=3","gravatar_id":"","url":"https://api.github.com/users/heroku","html_url":"https://github.com/heroku","followers_url":"https://api.github.com/users/heroku/followers","following_url":"https://api.github.com/users/heroku/following{/other_user}","gists_url":"https://api.github.com/users/heroku/gists{/gist_id}","starred_url":"https://api.github.com/users/heroku/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/heroku/subscriptions","organizations_url":"https://api.github.com/users/heroku/orgs","repos_url":"https://api.github.com/users/heroku/repos","events_url":"https://api.github.com/users/heroku/events{/privacy}","received_events_url":"https://api.github.com/users/heroku/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/heroku/retrodot","description":"A self-service tool to automate the facilitation, collection and system of record for the retrospective process","fork":false,"url":"https://api.github.com/repos/heroku/retrodot","forks_url":"https://api.github.com/repos/heroku/retrodot/forks","keys_url":"https://api.github.com/repos/heroku/retrodot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/heroku/retrodot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/heroku/retrodot/teams","hooks_url":"https://api.github.com/repos/heroku/retrodot/hooks","issue_events_url":"https://api.github.com/repos/heroku/retrodot/issues/events{/number}","events_url":"https://api.github.com/repos/heroku/retrodot/events","assignees_url":"https://api.github.com/repos/heroku/retrodot/assignees{/user}","branches_url":"https://api.github.com/repos/heroku/retrodot/branches{/branch}","tags_url":"https://api.github.com/repos/heroku/retrodot/tags","blobs_url":"https://api.github.com/repos/heroku/retrodot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/heroku/retrodot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/heroku/retrodot/git/refs{/sha}","trees_url":"https://api.github.com/repos/heroku/retrodot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/heroku/retrodot/statuses/{sha}","languages_url":"https://api.github.com/repos/heroku/retrodot/languages","stargazers_url":"https://api.github.com/repos/heroku/retrodot/stargazers","contributors_url":"https://api.github.com/repos/heroku/retrodot/contributors","subscribers_url":"https://api.github.com/repos/heroku/retrodot/subscribers","subscription_url":"https://api.github.com/repos/heroku/retrodot/subscription","commits_url":"https://api.github.com/repos/heroku/retrodot/commits{/sha}","git_commits_url":"https://api.github.com/repos/heroku/retrodot/git/commits{/sha}","comments_url":"https://api.github.com/repos/heroku/retrodot/comments{/number}","issue_comment_url":"https://api.github.com/repos/heroku/retrodot/issues/comments{/number}","contents_url":"https://api.github.com/repos/heroku/retrodot/contents/{+path}","compare_url":"https://api.github.com/repos/heroku/retrodot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/heroku/retrodot/merges","archive_url":"https://api.github.com/repos/heroku/retrodot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/heroku/retrodot/downloads","issues_url":"https://api.github.com/repos/heroku/retrodot/issues{/number}","pulls_url":"https://api.github.com/repos/heroku/retrodot/pulls{/number}","milestones_url":"https://api.github.com/repos/heroku/retrodot/milestones{/number}","notifications_url":"https://api.github.com/repos/heroku/retrodot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/heroku/retrodot/labels{/name}","releases_url":"https://api.github.com/repos/heroku/retrodot/releases{/id}","deployments_url":"https://api.github.com/repos/heroku/retrodot/deployments","created_at":"2016-08-03T12:51:55Z","updated_at":"2016-09-01T14:23:25Z","pushed_at":"2016-09-20T21:04:30Z","git_url":"git://github.com/heroku/retrodot.git","ssh_url":"git@github.com:heroku/retrodot.git","clone_url":"https://github.com/heroku/retrodot.git","svn_url":"https://github.com/heroku/retrodot","homepage":null,"size":300,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":0,"forks":2,"open_issues":0,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/heroku/retrodot/pulls/44"},"html":{"href":"https://github.com/heroku/retrodot/pull/44"},"issue":{"href":"https://api.github.com/repos/heroku/retrodot/issues/44"},"comments":{"href":"https://api.github.com/repos/heroku/retrodot/issues/44/comments"},"review_comments":{"href":"https://api.github.com/repos/heroku/retrodot/pulls/44/comments"},"review_comment":{"href":"https://api.github.com/repos/heroku/retrodot/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/heroku/retrodot/pulls/44/commits"},"statuses":{"href":"https://api.github.com/repos/heroku/retrodot/statuses/76fe325c0419dbbbef64fe67fb4a4dcc813396c8"}}}}
{"actor":{"display_login":"reidmix"}}