diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2016-02-18 20:11:12 +0100 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2016-02-22 17:26:24 +0100 |
commit | d88d443bbe5c5dabe45b44760108fa7b506cd7d9 (patch) | |
tree | 6e24e8e370fdb477518a57626ea19a19a9397a7a /server/sonar-web/src | |
parent | 978f9e79abcf71dfc5f477dbce5456578f56fa6f (diff) | |
download | sonarqube-d88d443bbe5c5dabe45b44760108fa7b506cd7d9.tar.gz sonarqube-d88d443bbe5c5dabe45b44760108fa7b506cd7d9.zip |
SONAR-7364 Remove SQALE characteristics from measures and rules
Diffstat (limited to 'server/sonar-web/src')
12 files changed, 55 insertions, 144 deletions
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/resources_controller.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/resources_controller.rb index 5b7e125356c..c13baa7a803 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/resources_controller.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/resources_controller.rb @@ -185,7 +185,6 @@ class Api::ResourcesController < Api::ApiController measures_conditions << 'project_measures.person_id IS NULL' add_rule_filters(measures_conditions, measures_values) - add_characteristic_filters(measures_conditions, measures_values) measures=ProjectMeasure.all(:joins => :snapshot, :select => select_columns_for_measures, @@ -281,7 +280,7 @@ class Api::ResourcesController < Api::ApiController end def select_columns_for_measures - select_columns='project_measures.id,project_measures.value,project_measures.metric_id,project_measures.snapshot_id,project_measures.rule_id,project_measures.text_value,project_measures.characteristic_id,project_measures.measure_data' + select_columns='project_measures.id,project_measures.value,project_measures.metric_id,project_measures.snapshot_id,project_measures.rule_id,project_measures.text_value,project_measures.measure_data' if params[:includetrends]=='true' select_columns+=',project_measures.variation_value_1,project_measures.variation_value_2,project_measures.variation_value_3,project_measures.variation_value_4,project_measures.variation_value_5' end @@ -311,24 +310,6 @@ class Api::ResourcesController < Api::ApiController end - def add_characteristic_filters(measures_conditions, measures_values) - @characteristics=[] - @characteristic_by_id={} - if params[:characteristics].present? - @characteristics=Characteristic.all(:select => 'characteristics.id,characteristics.kee,characteristics.name', - :conditions => ['characteristics.kee IN (?)', params[:characteristics].split(',')]) - if @characteristics.empty? - measures_conditions<<'project_measures.characteristic_id=-1' - else - @characteristics.each { |c| @characteristic_by_id[c.id]=c } - measures_conditions<<'project_measures.characteristic_id IN (:characteristics)' - measures_values[:characteristics]=@characteristic_by_id.keys - end - else - measures_conditions<<'project_measures.characteristic_id IS NULL' - end - end - def to_json(objects) resources = objects[:sorted_resources] snapshots_by_rid = objects[:snapshots_by_rid] @@ -439,11 +420,6 @@ class Api::ResourcesController < Api::ApiController json_measure[:rule_key] = rule.key if rule json_measure[:rule_name] = rule.name if rule end - if measure.characteristic_id - characteristic=@characteristic_by_id[measure.characteristic_id] - json_measure[:ctic_key]=(characteristic ? characteristic.kee : '') - json_measure[:ctic_name]=(characteristic ? characteristic.name : '') - end end end json @@ -523,11 +499,6 @@ class Api::ResourcesController < Api::ApiController xml.rule_key(rule.key) if rule xml.rule_name(rule.name) if rule end - if measure.characteristic_id - characteristic=@characteristic_by_id[measure.characteristic_id] - xml.ctic_key(characteristic ? characteristic.kee : '') - xml.ctic_name(characteristic ? characteristic.name : '') - end end end end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/timemachine_controller.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/timemachine_controller.rb index ce04dd62885..037dadd20df 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/timemachine_controller.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/timemachine_controller.rb @@ -22,22 +22,19 @@ require 'fastercsv' class Api::TimemachineController < Api::ApiController MAX_IN_ELEMENTS=990 - class MetadataId < Struct.new(:metric_id, :characteristic_id) + class MetadataId < Struct.new(:metric_id) end - class Metadata < Struct.new(:metric, :characteristic) + class Metadata < Struct.new(:metric) def to_id @id ||= begin - MetadataId.new(self.metric.id, self.characteristic && self.characteristic.id) + MetadataId.new(self.metric.id) end end def to_s label=self.metric.key - if self.characteristic - label+="(#{characteristic.key})" - end label end end @@ -53,8 +50,6 @@ class Api::TimemachineController < Api::ApiController # Optional parameters : # - fromDateTime # - toDateTime - # - model - # - characteristics # def index begin @@ -95,16 +90,9 @@ class Api::TimemachineController < Api::ApiController sql_conditions << 'project_measures.metric_id IN (:metrics)' sql_values[:metrics] = @metrics.select{|m| m.id} - if @characteristics.empty? - sql_conditions<<'project_measures.characteristic_id IS NULL' - else - sql_conditions<<'project_measures.characteristic_id IN (:characteristics)' - sql_values[:characteristics]=@characteristics.select{|c| c.id} - end - measures = ProjectMeasure.find(:all, :joins => :snapshot, - :select => 'project_measures.id,project_measures.value,project_measures.text_value,project_measures.metric_id,project_measures.snapshot_id,project_measures.characteristic_id,snapshots.created_at', + :select => 'project_measures.id,project_measures.value,project_measures.text_value,project_measures.metric_id,project_measures.snapshot_id,snapshots.created_at', :conditions => [sql_conditions.join(' AND '), sql_values], :order => 'snapshots.created_at') @@ -118,7 +106,7 @@ class Api::TimemachineController < Api::ApiController @sids<<m.snapshot_id @dates_by_sid[m.snapshot_id]=date_column.type_cast(m.attributes['created_at']) @measures_by_sid[m.snapshot_id]||={} - @measures_by_sid[m.snapshot_id][MetadataId.new(m.metric_id, m.characteristic_id)]=m + @measures_by_sid[m.snapshot_id][MetadataId.new(m.metric_id)]=m end @sids.uniq! end @@ -148,30 +136,12 @@ class Api::TimemachineController < Api::ApiController end end - def load_characteristics - if params[:model].present? && params[:characteristics].present? - @characteristics=Characteristic.find(:all, - :select => 'characteristics.id,characteristics.kee,characteristics.name', - :joins => :quality_model, - :conditions => ['quality_models.name=? AND characteristics.kee IN (?)', params[:model], params[:characteristics].split(',')]) - else - @characteristics=[] - end - end - def load_metadata load_metrics - load_characteristics @metadata=[] @metrics.each do |metric| - if @characteristics.empty? - @metadata<<Metadata.new(metric, nil) - else - @characteristics.each do |characteristic| - @metadata<<Metadata.new(metric, characteristic) - end - end + @metadata<<Metadata.new(metric) end @metadata end @@ -183,10 +153,6 @@ class Api::TimemachineController < Api::ApiController @metadata.each do |metadata| col={:metric => metadata.metric.key} - if metadata.characteristic - col[:model]=characteristic.model.name - col[:characteristic]=characteristic.kee - end cols<<col end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/drilldown_controller.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/drilldown_controller.rb index 53b1bb096cd..2010fc86433 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/drilldown_controller.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/drilldown_controller.rb @@ -42,12 +42,6 @@ class DrilldownController < ApplicationController # options options={} - if params[:characteristic_id] - @characteristic=Characteristic.find(params[:characteristic_id]) - elsif params[:characteristic] - @characteristic=Characteristic.find(:first, :conditions => ['characteristics.kee=? AND characteristics.enabled=?', params[:characteristic], true]) - end - options[:characteristic]=@characteristic if params[:period] && Api::Utils.valid_period_index?(params[:period]) @period=params[:period].to_i options[:period]=@period diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/components_helper.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/components_helper.rb index 64f83d1f554..ffb0b1727f3 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/components_helper.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/components_helper.rb @@ -68,7 +68,7 @@ module ComponentsHelper return nil if items.nil? items.each do |item| metric = Metric.by_name(metric_name) - return item if (item && metric && item.metric_id==metric.id && item.characteristic_id.nil? && item.person_id.nil?) + return item if (item && metric && item.metric_id==metric.id && item.person_id.nil?) end nil end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/drilldown.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/models/drilldown.rb index bbd44a080e0..2da5ce2ba10 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/drilldown.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/models/drilldown.rb @@ -122,13 +122,6 @@ class DrilldownColumn conditions += ' AND project_measures.rule_id IS NULL ' end - if options[:characteristic] - conditions += ' AND project_measures.characteristic_id=:characteristic_id' - condition_values[:characteristic_id]=options[:characteristic].id - else - conditions += ' AND project_measures.characteristic_id IS NULL' - end - if @person_id conditions += ' AND project_measures.person_id=:person_id' condition_values[:person_id]=@person_id diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/measure_filter.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/models/measure_filter.rb index 255f6355966..f96887b5ded 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/measure_filter.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/models/measure_filter.rb @@ -277,7 +277,7 @@ class MeasureFilter < ActiveRecord::Base measures = [] snapshot_ids.each_slice(999) do |safe_for_oracle_ids| measures.concat(ProjectMeasure.all(:conditions => - ['rule_priority is null and rule_id is null and characteristic_id is null and person_id is null and snapshot_id in (?) and metric_id in (?)', safe_for_oracle_ids, metric_ids] + ['rule_priority is null and rule_id is null and person_id is null and snapshot_id in (?) and metric_id in (?)', safe_for_oracle_ids, metric_ids] )) end measures.each do |measure| @@ -313,7 +313,7 @@ class MeasureFilter < ActiveRecord::Base @base_row = Row.new(base_snapshot) unless metric_ids.empty? base_measures = ProjectMeasure.all(:conditions => - ['rule_priority is null and rule_id is null and characteristic_id is null and person_id is null and snapshot_id=? and metric_id in (?)', base_snapshot.id, metric_ids] + ['rule_priority is null and rule_id is null and person_id is null and snapshot_id=? and metric_id in (?)', base_snapshot.id, metric_ids] ) base_measures.each do |base_measure| @base_row.add_measure(base_measure) diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/project_measure.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/models/project_measure.rb index 4b42ca50ded..ed9b2dc0e24 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/project_measure.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/models/project_measure.rb @@ -28,7 +28,6 @@ class ProjectMeasure < ActiveRecord::Base belongs_to :snapshot belongs_to :rule belongs_to :project - belongs_to :characteristic belongs_to :person, :class_name => 'Project', :foreign_key => 'person_id' def metric @@ -245,8 +244,6 @@ class ProjectMeasure < ActiveRecord::Base if rule_measure? if rule_id "#{metric_key}_rule_#{rule_id}" - elsif characteristic_id - "#{metric_key}_c_#{characteristic_id}" end else metric_key diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/snapshot.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/models/snapshot.rb index fd175224e56..ebbd2eb771f 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/snapshot.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/models/snapshot.rb @@ -25,12 +25,10 @@ class Snapshot < ActiveRecord::Base belongs_to :root_project, :class_name => 'Project', :foreign_key => 'root_project_id' belongs_to :parent_snapshot, :class_name => 'Snapshot', :foreign_key => 'parent_snapshot_id' belongs_to :root_snapshot, :class_name => 'Snapshot', :foreign_key => 'root_snapshot_id' - belongs_to :characteristic - has_many :measures, :class_name => 'ProjectMeasure', :conditions => 'rule_id IS NULL AND characteristic_id IS NULL AND person_id IS NULL' - has_many :rulemeasures, :class_name => 'ProjectMeasure', :conditions => 'rule_id IS NOT NULL AND characteristic_id IS NULL AND person_id IS NULL', :include => 'rule' - has_many :characteristic_measures, :class_name => 'ProjectMeasure', :conditions => 'rule_id IS NULL AND characteristic_id IS NOT NULL AND person_id IS NULL' - has_many :person_measures, :class_name => 'ProjectMeasure', :conditions => 'rule_id IS NULL AND characteristic_id IS NULL AND person_id IS NOT NULL' + has_many :measures, :class_name => 'ProjectMeasure', :conditions => 'rule_id IS NULL AND person_id IS NULL' + has_many :rulemeasures, :class_name => 'ProjectMeasure', :conditions => 'rule_id IS NOT NULL AND person_id IS NULL', :include => 'rule' + has_many :person_measures, :class_name => 'ProjectMeasure', :conditions => 'rule_id IS NULL AND person_id IS NOT NULL' has_many :events, :dependent => :destroy, :order => 'event_date DESC' @@ -184,13 +182,6 @@ class Snapshot < ActiveRecord::Base nil end - def characteristic_measure(metric, characteristic) - characteristic_measures.each do |m| - return m if m.metric_id==metric.id && m.characteristic==characteristic - end - nil - end - def f_measure(metric) m=measure(metric) m && m.formatted_value diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/trends_chart.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/models/trends_chart.rb index fd1bb816517..2510866597d 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/trends_chart.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/models/trends_chart.rb @@ -27,7 +27,7 @@ class TrendsChart " and s.status=? " + " and s.project_id=? " + " and m.metric_id in (?) " + - " and m.rule_priority is null and m.characteristic_id is null and m.person_id is null" + " and m.rule_priority is null and m.person_id is null" if (options[:from]) sql += ' and s.created_at>=?' end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/drilldown/measures.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/drilldown/measures.html.erb index 56d086e1fa9..f31229f1407 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/drilldown/measures.html.erb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/views/drilldown/measures.html.erb @@ -32,17 +32,11 @@ <% end %> <div class="marginbottom10"> - <% if @characteristic %> - <h3><%= @highlighted_metric.short_name -%> / <%= h(@characteristic.name(true)) -%></h3> + <h3><%= @highlighted_metric.short_name -%></h3> - <p class="big"><%= format_measure(@snapshot.characteristic_measure(@highlighted_metric, @characteristic)) %></p> - <% else %> - <h3><%= @highlighted_metric.short_name -%></h3> - - <p class="big"> - <%= format_measure(@snapshot.measure(@highlighted_metric.key), :period => @period) %> - </p> - <% end %> + <p class="big"> + <%= format_measure(@snapshot.measure(@highlighted_metric.key), :period => @period) %> + </p> <% if @highlighted_metric!=@metric %> <p> <%= message('drilldown.drilldown_on') -%> diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/characteristic.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1102_delete_measures_with_characteristic_id.rb index 2633ee39b42..12e885a0a8b 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/characteristic.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1102_delete_measures_with_characteristic_id.rb @@ -17,40 +17,15 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # -class Characteristic < ActiveRecord::Base - NAME_MAX_SIZE=100 - - FUNCTION_CONSTANT_ISSUE = "constant_issue"; - FUNCTION_LINEAR = "linear"; - FUNCTION_LINEAR_WITH_OFFSET = "linear_offset"; - - DAY = "d" - HOUR = "h" - MINUTE = "mn" - - belongs_to :parent, :class_name => 'Characteristic', :foreign_key => 'parent_id' - - # Needed for Views Plugin. Remove it when the plugin will not used it anymore - belongs_to :rule - - validates_uniqueness_of :name, :scope => [:enabled], :case_sensitive => false, :if => Proc.new { |c| c.enabled } - validates_length_of :name, :in => 1..NAME_MAX_SIZE, :allow_blank => false - - def root? - parent_id.nil? - end - - def requirement? - rule_id.nil? - end - - def key - kee - end +# +# SonarQube 5.5 +# SONAR-7364 +# +class DeleteMeasuresWithCharacteristicId < ActiveRecord::Migration - def name(rule_name_if_empty=false) - read_attribute(:name) + def self.up + execute_java_migration('org.sonar.db.version.v55.DeleteMeasuresWithCharacteristicId') end end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1103_drop_table_characteristics.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1103_drop_table_characteristics.rb new file mode 100644 index 00000000000..65b6c24cae9 --- /dev/null +++ b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1103_drop_table_characteristics.rb @@ -0,0 +1,30 @@ +# +# SonarQube, open source software quality management tool. +# Copyright (C) 2008-2014 SonarSource +# mailto:contact AT sonarsource DOT com +# +# SonarQube is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 3 of the License, or (at your option) any later version. +# +# SonarQube is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# +# SonarQube 5.5 +# SONAR-7364 +class DropTableCharacteristics < ActiveRecord::Migration + + def self.up + drop_table 'characteristics' + end + +end + |