aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server/src/main/webapp/WEB-INF/app/models/profile.rb
diff options
context:
space:
mode:
authorsimonbrandhof <simon.brandhof@gmail.com>2010-09-07 23:53:42 +0000
committersimonbrandhof <simon.brandhof@gmail.com>2010-09-07 23:53:42 +0000
commit7a07af0d844c1bb30b2c7df4aeafa0642fc7ce2f (patch)
tree339f625242b165d546562bbaa8c30f43e3f4db98 /sonar-server/src/main/webapp/WEB-INF/app/models/profile.rb
parent3cc63963cfd20176c605c27f023fb6e70db69b80 (diff)
downloadsonarqube-7a07af0d844c1bb30b2c7df4aeafa0642fc7ce2f.tar.gz
sonarqube-7a07af0d844c1bb30b2c7df4aeafa0642fc7ce2f.zip
SONAR-1654 Export rules in rules engine exports everything (Java, PHP, VB...) when you select any in plugins
+ sort quality profiles by language
Diffstat (limited to 'sonar-server/src/main/webapp/WEB-INF/app/models/profile.rb')
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/models/profile.rb27
1 files changed, 27 insertions, 0 deletions
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 bf615b3fc64..064174f54ba 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
@@ -23,6 +23,8 @@ class Profile < ActiveRecord::Base
has_many :alerts, :dependent => :delete_all
has_many :active_rules, :class_name => 'ActiveRule', :foreign_key => 'profile_id', :dependent => :destroy, :include => ['rule']
has_many :projects, :order => 'name asc'
+ has_many :active_rules_with_params, :class_name => 'ActiveRule', :foreign_key => 'profile_id',
+ :include => ['active_rule_parameters']
validates_uniqueness_of :name, :scope => :language, :case_sensitive => false
validates_presence_of :name
@@ -73,4 +75,29 @@ class Profile < ActiveRecord::Base
end
self
end
+
+ def active_by_rule_id(rule_id)
+ active_hash_by_rule_id[rule_id]
+ end
+
+ def self.options_for_select
+ array=[]
+ RulesProfile.find(:all, :order => 'name').each do |profile|
+ label = profile.name
+ label = label + ' (active)' if profile.default_profile?
+ array<<[label, profile.id]
+ end
+ array
+ end
+
+ @active_hash_by_rule_id=nil
+ def active_hash_by_rule_id
+ if @active_hash_by_rule_id.nil?
+ @active_hash_by_rule_id={}
+ active_rules_with_params.each do |active_rule|
+ @active_hash_by_rule_id[active_rule.rule_id]=active_rule
+ end
+ end
+ @active_hash_by_rule_id
+ end
end