From 68e0d61fb8da83c52e1cc483cc25c9bebdcae10c Mon Sep 17 00:00:00 2001 From: Raja Bhadury Date: Mon, 21 Feb 2011 17:25:27 +0000 Subject: [PATCH] Turn on/off email notifications for deploys and errors on a per-application basis. Allow message with deploy notifications (so we know what is was for). Add index to errors to speed up viewing them. --- app/controllers/deploys_controller.rb | 5 ++++- app/models/app.rb | 2 ++ app/models/deploy.rb | 3 ++- app/models/err.rb | 1 + app/models/notice.rb | 2 +- app/views/apps/_fields.html.haml | 10 +++++++++- app/views/apps/show.html.haml | 2 ++ app/views/deploys/_table.html.haml | 2 ++ 8 files changed, 23 insertions(+), 4 deletions(-) diff --git a/app/controllers/deploys_controller.rb b/app/controllers/deploys_controller.rb index 361a125..0ff1afd 100644 --- a/app/controllers/deploys_controller.rb +++ b/app/controllers/deploys_controller.rb @@ -1,4 +1,6 @@ class DeploysController < ApplicationController + + protect_from_forgery :except => :create skip_before_filter :verify_authenticity_token, :only => :create skip_before_filter :authenticate_user!, :only => :create @@ -9,7 +11,8 @@ class DeploysController < ApplicationController :username => params[:deploy][:local_username], :environment => params[:deploy][:rails_env], :repository => params[:deploy][:scm_repository], - :revision => params[:deploy][:scm_revision] + :revision => params[:deploy][:scm_revision], + :message => params[:deploy][:message] }) render :xml => @deploy end diff --git a/app/models/app.rb b/app/models/app.rb index 42c317a..28ce850 100644 --- a/app/models/app.rb +++ b/app/models/app.rb @@ -5,6 +5,8 @@ class App field :name, :type => String field :api_key field :resolve_errs_on_deploy, :type => Boolean, :default => false + field :notify_on_errs, :type => Boolean, :default => false + field :notify_on_deploys, :type => Boolean, :default => false key :name embeds_many :watchers diff --git a/app/models/deploy.rb b/app/models/deploy.rb index c8b4fac..3e9a790 100644 --- a/app/models/deploy.rb +++ b/app/models/deploy.rb @@ -6,6 +6,7 @@ class Deploy field :repository field :environment field :revision + field :message index :created_at, Mongo::DESCENDING @@ -27,7 +28,7 @@ class Deploy protected def should_notify? - app.watchers.any? + app.notify_on_deploys? && app.watchers.any? end def should_resolve_app_errs? diff --git a/app/models/err.rb b/app/models/err.rb index a436768..93ed290 100644 --- a/app/models/err.rb +++ b/app/models/err.rb @@ -13,6 +13,7 @@ class Err field :resolved, :type => Boolean, :default => false index :last_notice_at + index :app_id referenced_in :app embeds_many :notices diff --git a/app/models/notice.rb b/app/models/notice.rb index 694d95c..83b5ce1 100644 --- a/app/models/notice.rb +++ b/app/models/notice.rb @@ -73,7 +73,7 @@ class Notice protected def should_notify? - Errbit::Config.email_at_notices.include?(err.notices.count) && err.app.watchers.any? + err.app.notify_on_errs? && Errbit::Config.email_at_notices.include?(err.notices.count) && err.app.watchers.any? end end \ No newline at end of file diff --git a/app/views/apps/_fields.html.haml b/app/views/apps/_fields.html.haml index 0a2c820..d9d0596 100644 --- a/app/views/apps/_fields.html.haml +++ b/app/views/apps/_fields.html.haml @@ -5,9 +5,17 @@ = f.text_field :name %div.checkbox + = f.check_box :notify_on_errs + = f.label :notify_on_errs, 'Notify on errors' + +%div.checkbox = f.check_box :resolve_errs_on_deploy = f.label :resolve_errs_on_deploy, 'Resolve errs on deploy' - + +%div.checkbox + = f.check_box :notify_on_deploys + = f.label :notify_on_deploys, 'Notify on deploys' + %fieldset.nested-wrapper %legend Watchers - f.fields_for :watchers do |w| diff --git a/app/views/apps/show.html.haml b/app/views/apps/show.html.haml index 5c70b10..f4d40b6 100644 --- a/app/views/apps/show.html.haml +++ b/app/views/apps/show.html.haml @@ -32,6 +32,7 @@ %tr %th When %th Who + %th Message %th Repository %th Revision @@ -40,6 +41,7 @@ %tr %td.when #{deploy.created_at.to_s(:micro)} %td.who #{deploy.username} + %td.message #{deploy.message} %td.repository #{deploy.repository} %td.revision #{deploy.revision} = link_to "All Deploys (#{@app.deploys.count})", app_deploys_path(@app), :class => 'button' diff --git a/app/views/deploys/_table.html.haml b/app/views/deploys/_table.html.haml index 18ecb5e..6a70bad 100644 --- a/app/views/deploys/_table.html.haml +++ b/app/views/deploys/_table.html.haml @@ -4,6 +4,7 @@ %th App %th When %th Who + %th Message %th Repository %th Revision %tbody @@ -14,5 +15,6 @@ %span.environment= deploy.environment %td.latest #{time_ago_in_words(deploy.created_at)} ago %td.who #{deploy.username} + %td.message #{deploy.message} %td.repository #{deploy.repository} %td.revision #{deploy.revision} -- libgit2 0.21.2