aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@gmail.com>2013-01-18 15:20:28 +0100
committerJulien Lancelot <julien.lancelot@gmail.com>2013-01-18 15:20:44 +0100
commit5ab69aedad1e97e6339bb313e1e50bbfb6f872c7 (patch)
treecb988d53dde9b9e83a7dc751ffcc6fd5e1c9dff5
parent6cdb0c5c809a86f69599f2006a6b2d1b29e24499 (diff)
downloadsonarqube-5ab69aedad1e97e6339bb313e1e50bbfb6f872c7.tar.gz
sonarqube-5ab69aedad1e97e6339bb313e1e50bbfb6f872c7.zip
SONAR-1110 Alerts with deleted metric are no more displayed on quality alerts page
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/alerts_controller.rb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/api/profiles_controller.rb4
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/models/profile.rb4
3 files changed, 7 insertions, 3 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/alerts_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/alerts_controller.rb
index 29acd43b3d0..968c75553b0 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/alerts_controller.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/alerts_controller.rb
@@ -32,7 +32,7 @@ class AlertsController < ApplicationController
def index
require_parameters :id
@profile = Profile.find(params[:id])
- @alerts = @profile.alerts.sort
+ @alerts = @profile.valid_alerts.sort
@alert=Alert.new
add_breadcrumbs ProfilesController::ROOT_BREADCRUMB, Api::Utils.language_name(@profile.language), {:name => @profile.name, :url => {:controller => 'rules_configuration', :action => 'index', :id => @profile.id}}
end
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/profiles_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/profiles_controller.rb
index 659ecfb0f71..68b237ebac1 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/profiles_controller.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/profiles_controller.rb
@@ -193,7 +193,7 @@ class Api::ProfilesController < Api::ApiController
result[:rules]=rules unless rules.empty?
alerts=[]
- @profile.alerts.each do |alert|
+ @profile.valid_alerts.each do |alert|
alert_hash={:metric => alert.metric.key, :operator => alert.operator}
alert_hash[:error]=alert.value_error if alert.value_error.present?
alert_hash[:warning]=alert.value_warning if alert.value_warning.present?
@@ -228,7 +228,7 @@ class Api::ProfilesController < Api::ApiController
end
end
- @profile.alerts.each do |alert|
+ @profile.valid_alerts.each do |alert|
xml.alert do
xml.metric(alert.metric.key)
xml.operator(alert.operator)
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/profile.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/profile.rb
index 57012bf4ae1..1ce2b3f0d23 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/models/profile.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/models/profile.rb
@@ -207,6 +207,10 @@ class Profile < ActiveRecord::Base
@projects = nil
end
+ def valid_alerts
+ alerts.reject {|alert| alert.metric.nil? || !alert.metric.enabled }
+ end
+
def to_hash_json
{
:name => name,