From 29d146fc3a558a8f2c8f3eb657f3f5832382c570 Mon Sep 17 00:00:00 2001 From: Evgeny Mandrikov Date: Tue, 7 Feb 2012 17:49:10 +0400 Subject: [PATCH] SONAR-3231 Allow to use committer for measures drilldown --- .../app/controllers/drilldown_controller.rb | 5 +++++ .../main/webapp/WEB-INF/app/models/drilldown.rb | 7 ++++++- .../main/webapp/WEB-INF/app/models/snapshot.rb | 8 ++++++++ .../WEB-INF/app/views/drilldown/measures.html.erb | 15 +++++++++++++-- 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/drilldown_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/drilldown_controller.rb index 58fca07c795..700160f9df2 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/drilldown_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/drilldown_controller.rb @@ -53,6 +53,11 @@ class DrilldownController < ApplicationController options[:period]=@period end + if params[:committer] + @committer=params[:committer] + options[:committer]=@committer + end + # load data @drilldown = Drilldown.new(@project, @metric, selected_rids, options) @snapshot = @drilldown.snapshot diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/drilldown.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/drilldown.rb index c198930fe3c..c6c4198a4c1 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/drilldown.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/drilldown.rb @@ -91,7 +91,12 @@ class DrilldownColumn conditions += ' AND project_measures.characteristic_id IS NULL' end - conditions += ' AND project_measures.committer IS NULL' + if options[:committer] + conditions += ' AND project_measures.committer=:committer' + condition_values[:committer]=options[:committer] + else + conditions += ' AND project_measures.committer IS NULL' + end @measures=ProjectMeasure.find(:all, :select => "project_measures.id,project_measures.metric_id,project_measures.#{value_column},project_measures.text_value,project_measures.alert_status,project_measures.alert_text,project_measures.snapshot_id", diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/snapshot.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/snapshot.rb index e840b1665e3..872efacc480 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/snapshot.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/snapshot.rb @@ -30,6 +30,7 @@ class Snapshot < ActiveRecord::Base has_many :measures, :class_name => 'ProjectMeasure', :conditions => 'rule_id IS NULL AND characteristic_id IS NULL AND committer IS NULL' has_many :rulemeasures, :class_name => 'ProjectMeasure', :conditions => 'rule_id IS NOT NULL AND characteristic_id IS NULL AND committer IS NULL', :include => 'rule' has_many :characteristic_measures, :class_name => 'ProjectMeasure', :conditions => 'rule_id IS NULL AND characteristic_id IS NOT NULL AND committer IS NULL' + has_many :committer_measures, :class_name => 'ProjectMeasure', :conditions => 'rule_id IS NULL AND characteristic_id IS NULL AND committer IS NOT NULL' has_many :events, :dependent => :destroy, :order => 'event_date DESC' has_one :source, :class_name => 'SnapshotSource', :dependent => :destroy @@ -163,6 +164,13 @@ class Snapshot < ActiveRecord::Base metric ? measures_hash[metric.id] : nil end + def committer_measure(metric, committer) + committer_measures.each do |m| + return m if m.metric_id==metric.id && m.committer==committer + end + nil + end + def characteristic_measure(metric, characteristic) characteristic_measures.each do |m| return m if m.metric_id==metric.id && m.characteristic==characteristic diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/measures.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/measures.html.erb index 979ede25764..4542b0651d1 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/measures.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/measures.html.erb @@ -20,7 +20,13 @@ <% end %>
- <% if @characteristic %> + <% if @committer %> +

<%= @highlighted_metric.short_name -%> / <%= h(@committer) -%>

+ +

+ <%= format_measure(@snapshot.committer_measure(@highlighted_metric, @committer), :period => @period) %> +

+ <% elsif @characteristic %>

<%= @highlighted_metric.short_name -%> / <%= h(@characteristic.name(true)) -%>

<%= format_measure(@snapshot.characteristic_measure(@highlighted_metric, @characteristic)) %>

@@ -37,7 +43,12 @@ <% if @highlighted_metric!=@metric %> <%= message('drilldown.drilldown_on') -%>  - <%= format_measure(@metric.key, :period => @period) -%> <%= @metric.short_name -%> + <% if @committer %> + <%= format_measure(@snapshot.committer_measure(@metric, @committer), :period => @period) -%> <%= @metric.short_name -%> + <% else %> + <%= format_measure(@metric.key, :period => @period) -%> <%= @metric.short_name -%> + <% end %> + <% end -- 2.39.5