{"action":"created","comment":{"url":"https://api.github.com/repos/FundingCircle/shipment_tracker/pulls/comments/55814616","id":55814616,"diff_hunk":"@@ -42,8 +32,28 @@ def last_staging_deploy_for_version(version)\n \n     def apply(event)\n       return unless event.is_a?(Events::DeployEvent)\n+      new_deploy = create_deploy_snapshot(event)\n+\n+      if DeployAlert.auditable?(new_deploy) && !Rails.configuration.data_maintenance_mode\n+        previous_deploy = second_last_production_deploy(new_deploy.app_name, new_deploy.region)\n+        audit_deploy(new_deploy: new_deploy.attributes, previous_deploy: previous_deploy&.attributes)\n+      end\n+    end\n+\n+    def second_last_production_deploy(app_name, region)\n+      store.where(app_name: app_name, environment: 'production', region: region)\n+           .order(id: 'desc')\n+           .limit(1)\n+           .offset(1)\n+           .first\n+    end\n+\n+    private\n \n-      deploy = store.create!(\n+    attr_reader :store\n+\n+    def create_deploy_snapshot(event)\n+      store.create(","path":"app/models/repositories/deploy_repository.rb","position":43,"original_position":43,"commit_id":"4b45ffc04890b57f237ae1ddae0f9c5aba4cabaf","original_commit_id":"4b45ffc04890b57f237ae1ddae0f9c5aba4cabaf","user":{"login":"andistuder","id":1047920,"avatar_url":"https://avatars.githubusercontent.com/u/1047920?v=3","gravatar_id":"","url":"https://api.github.com/users/andistuder","html_url":"https://github.com/andistuder","followers_url":"https://api.github.com/users/andistuder/followers","following_url":"https://api.github.com/users/andistuder/following{/other_user}","gists_url":"https://api.github.com/users/andistuder/gists{/gist_id}","starred_url":"https://api.github.com/users/andistuder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andistuder/subscriptions","organizations_url":"https://api.github.com/users/andistuder/orgs","repos_url":"https://api.github.com/users/andistuder/repos","events_url":"https://api.github.com/users/andistuder/events{/privacy}","received_events_url":"https://api.github.com/users/andistuder/received_events","type":"User","site_admin":false},"body":":no_entry_sign: you changed to `.create` without '!'. please keep `.create!`, ","created_at":"2016-03-11T10:39:28Z","updated_at":"2016-03-11T10:39:28Z","html_url":"https://github.com/FundingCircle/shipment_tracker/pull/126#discussion_r55814616","pull_request_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/pulls/126","_links":{"self":{"href":"https://api.github.com/repos/FundingCircle/shipment_tracker/pulls/comments/55814616"},"html":{"href":"https://github.com/FundingCircle/shipment_tracker/pull/126#discussion_r55814616"},"pull_request":{"href":"https://api.github.com/repos/FundingCircle/shipment_tracker/pulls/126"}}},"pull_request":{"url":"https://api.github.com/repos/FundingCircle/shipment_tracker/pulls/126","id":62065175,"html_url":"https://github.com/FundingCircle/shipment_tracker/pull/126","diff_url":"https://github.com/FundingCircle/shipment_tracker/pull/126.diff","patch_url":"https://github.com/FundingCircle/shipment_tracker/pull/126.patch","issue_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/issues/126","number":126,"state":"open","locked":false,"title":"Update deploy alert message","user":{"login":"0mega","id":519615,"avatar_url":"https://avatars.githubusercontent.com/u/519615?v=3","gravatar_id":"","url":"https://api.github.com/users/0mega","html_url":"https://github.com/0mega","followers_url":"https://api.github.com/users/0mega/followers","following_url":"https://api.github.com/users/0mega/following{/other_user}","gists_url":"https://api.github.com/users/0mega/gists{/gist_id}","starred_url":"https://api.github.com/users/0mega/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/0mega/subscriptions","organizations_url":"https://api.github.com/users/0mega/orgs","repos_url":"https://api.github.com/users/0mega/repos","events_url":"https://api.github.com/users/0mega/events{/privacy}","received_events_url":"https://api.github.com/users/0mega/received_events","type":"User","site_admin":false},"body":"- Updates alert message\r\n- Makes slack channel for notifications configurable\r\n- Adds deployment verification rules:\r\n  - Alert if a deploy contains at least one version which was not approved","created_at":"2016-03-08T12:35:52Z","updated_at":"2016-03-11T10:39:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0022700c161890a579a7712336b078a4d8ade43a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/pulls/126/commits","review_comments_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/pulls/126/comments","review_comment_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/pulls/comments{/number}","comments_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/issues/126/comments","statuses_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/statuses/4b45ffc04890b57f237ae1ddae0f9c5aba4cabaf","head":{"label":"FundingCircle:deploy-alerting","ref":"deploy-alerting","sha":"4b45ffc04890b57f237ae1ddae0f9c5aba4cabaf","user":{"login":"FundingCircle","id":834834,"avatar_url":"https://avatars.githubusercontent.com/u/834834?v=3","gravatar_id":"","url":"https://api.github.com/users/FundingCircle","html_url":"https://github.com/FundingCircle","followers_url":"https://api.github.com/users/FundingCircle/followers","following_url":"https://api.github.com/users/FundingCircle/following{/other_user}","gists_url":"https://api.github.com/users/FundingCircle/gists{/gist_id}","starred_url":"https://api.github.com/users/FundingCircle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FundingCircle/subscriptions","organizations_url":"https://api.github.com/users/FundingCircle/orgs","repos_url":"https://api.github.com/users/FundingCircle/repos","events_url":"https://api.github.com/users/FundingCircle/events{/privacy}","received_events_url":"https://api.github.com/users/FundingCircle/received_events","type":"Organization","site_admin":false},"repo":{"id":34510688,"name":"shipment_tracker","full_name":"FundingCircle/shipment_tracker","owner":{"login":"FundingCircle","id":834834,"avatar_url":"https://avatars.githubusercontent.com/u/834834?v=3","gravatar_id":"","url":"https://api.github.com/users/FundingCircle","html_url":"https://github.com/FundingCircle","followers_url":"https://api.github.com/users/FundingCircle/followers","following_url":"https://api.github.com/users/FundingCircle/following{/other_user}","gists_url":"https://api.github.com/users/FundingCircle/gists{/gist_id}","starred_url":"https://api.github.com/users/FundingCircle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FundingCircle/subscriptions","organizations_url":"https://api.github.com/users/FundingCircle/orgs","repos_url":"https://api.github.com/users/FundingCircle/repos","events_url":"https://api.github.com/users/FundingCircle/events{/privacy}","received_events_url":"https://api.github.com/users/FundingCircle/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/FundingCircle/shipment_tracker","description":"Tracks shipment of software versions for Financial Conduct Authority auditing purposes","fork":false,"url":"https://api.github.com/repos/FundingCircle/shipment_tracker","forks_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/forks","keys_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/teams","hooks_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/hooks","issue_events_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/issues/events{/number}","events_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/events","assignees_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/assignees{/user}","branches_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/branches{/branch}","tags_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/tags","blobs_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/git/refs{/sha}","trees_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/statuses/{sha}","languages_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/languages","stargazers_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/stargazers","contributors_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/contributors","subscribers_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/subscribers","subscription_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/subscription","commits_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/commits{/sha}","git_commits_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/git/commits{/sha}","comments_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/comments{/number}","issue_comment_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/issues/comments{/number}","contents_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/contents/{+path}","compare_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/merges","archive_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/downloads","issues_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/issues{/number}","pulls_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/pulls{/number}","milestones_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/milestones{/number}","notifications_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/labels{/name}","releases_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/releases{/id}","deployments_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/deployments","created_at":"2015-04-24T09:43:59Z","updated_at":"2016-02-23T19:50:36Z","pushed_at":"2016-03-11T09:30:44Z","git_url":"git://github.com/FundingCircle/shipment_tracker.git","ssh_url":"git@github.com:FundingCircle/shipment_tracker.git","clone_url":"https://github.com/FundingCircle/shipment_tracker.git","svn_url":"https://github.com/FundingCircle/shipment_tracker","homepage":"","size":1427,"stargazers_count":4,"watchers_count":4,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":6,"forks":2,"open_issues":6,"watchers":4,"default_branch":"master"}},"base":{"label":"FundingCircle:master","ref":"master","sha":"e8aae56f3d7de23823eedc3a4fc24e84d49864f9","user":{"login":"FundingCircle","id":834834,"avatar_url":"https://avatars.githubusercontent.com/u/834834?v=3","gravatar_id":"","url":"https://api.github.com/users/FundingCircle","html_url":"https://github.com/FundingCircle","followers_url":"https://api.github.com/users/FundingCircle/followers","following_url":"https://api.github.com/users/FundingCircle/following{/other_user}","gists_url":"https://api.github.com/users/FundingCircle/gists{/gist_id}","starred_url":"https://api.github.com/users/FundingCircle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FundingCircle/subscriptions","organizations_url":"https://api.github.com/users/FundingCircle/orgs","repos_url":"https://api.github.com/users/FundingCircle/repos","events_url":"https://api.github.com/users/FundingCircle/events{/privacy}","received_events_url":"https://api.github.com/users/FundingCircle/received_events","type":"Organization","site_admin":false},"repo":{"id":34510688,"name":"shipment_tracker","full_name":"FundingCircle/shipment_tracker","owner":{"login":"FundingCircle","id":834834,"avatar_url":"https://avatars.githubusercontent.com/u/834834?v=3","gravatar_id":"","url":"https://api.github.com/users/FundingCircle","html_url":"https://github.com/FundingCircle","followers_url":"https://api.github.com/users/FundingCircle/followers","following_url":"https://api.github.com/users/FundingCircle/following{/other_user}","gists_url":"https://api.github.com/users/FundingCircle/gists{/gist_id}","starred_url":"https://api.github.com/users/FundingCircle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FundingCircle/subscriptions","organizations_url":"https://api.github.com/users/FundingCircle/orgs","repos_url":"https://api.github.com/users/FundingCircle/repos","events_url":"https://api.github.com/users/FundingCircle/events{/privacy}","received_events_url":"https://api.github.com/users/FundingCircle/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/FundingCircle/shipment_tracker","description":"Tracks shipment of software versions for Financial Conduct Authority auditing purposes","fork":false,"url":"https://api.github.com/repos/FundingCircle/shipment_tracker","forks_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/forks","keys_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/teams","hooks_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/hooks","issue_events_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/issues/events{/number}","events_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/events","assignees_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/assignees{/user}","branches_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/branches{/branch}","tags_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/tags","blobs_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/git/refs{/sha}","trees_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/statuses/{sha}","languages_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/languages","stargazers_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/stargazers","contributors_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/contributors","subscribers_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/subscribers","subscription_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/subscription","commits_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/commits{/sha}","git_commits_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/git/commits{/sha}","comments_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/comments{/number}","issue_comment_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/issues/comments{/number}","contents_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/contents/{+path}","compare_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/merges","archive_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/downloads","issues_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/issues{/number}","pulls_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/pulls{/number}","milestones_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/milestones{/number}","notifications_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/labels{/name}","releases_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/releases{/id}","deployments_url":"https://api.github.com/repos/FundingCircle/shipment_tracker/deployments","created_at":"2015-04-24T09:43:59Z","updated_at":"2016-02-23T19:50:36Z","pushed_at":"2016-03-11T09:30:44Z","git_url":"git://github.com/FundingCircle/shipment_tracker.git","ssh_url":"git@github.com:FundingCircle/shipment_tracker.git","clone_url":"https://github.com/FundingCircle/shipment_tracker.git","svn_url":"https://github.com/FundingCircle/shipment_tracker","homepage":"","size":1427,"stargazers_count":4,"watchers_count":4,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":6,"forks":2,"open_issues":6,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/FundingCircle/shipment_tracker/pulls/126"},"html":{"href":"https://github.com/FundingCircle/shipment_tracker/pull/126"},"issue":{"href":"https://api.github.com/repos/FundingCircle/shipment_tracker/issues/126"},"comments":{"href":"https://api.github.com/repos/FundingCircle/shipment_tracker/issues/126/comments"},"review_comments":{"href":"https://api.github.com/repos/FundingCircle/shipment_tracker/pulls/126/comments"},"review_comment":{"href":"https://api.github.com/repos/FundingCircle/shipment_tracker/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/FundingCircle/shipment_tracker/pulls/126/commits"},"statuses":{"href":"https://api.github.com/repos/FundingCircle/shipment_tracker/statuses/4b45ffc04890b57f237ae1ddae0f9c5aba4cabaf"}}}}