aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server
diff options
context:
space:
mode:
authorEvgeny Mandrikov <mandrikov@gmail.com>2012-02-07 17:49:10 +0400
committerEvgeny Mandrikov <mandrikov@gmail.com>2012-02-07 18:38:20 +0400
commit29d146fc3a558a8f2c8f3eb657f3f5832382c570 (patch)
treea373335bb0e509c46c774f5671e58a799746f348 /sonar-server
parente43c4783cb230d7a03e17a09bcd33a299aa92227 (diff)
downloadsonarqube-29d146fc3a558a8f2c8f3eb657f3f5832382c570.tar.gz
sonarqube-29d146fc3a558a8f2c8f3eb657f3f5832382c570.zip
SONAR-3231 Allow to use committer for measures drilldown
Diffstat (limited to 'sonar-server')
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/drilldown_controller.rb5
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/models/drilldown.rb7
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/models/snapshot.rb8
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/measures.html.erb15
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 %>
<div class="dashbox">
- <% if @characteristic %>
+ <% if @committer %>
+ <h3><%= @highlighted_metric.short_name -%> / <%= h(@committer) -%></h3>
+
+ <p class="big">
+ <%= format_measure(@snapshot.committer_measure(@highlighted_metric, @committer), :period => @period) %>
+ </p>
+ <% elsif @characteristic %>
<h3><%= @highlighted_metric.short_name -%> / <%= h(@characteristic.name(true)) -%></h3>
<p class="big"><%= format_measure(@snapshot.characteristic_measure(@highlighted_metric, @characteristic)) %></p>
@@ -37,7 +43,12 @@
<% if @highlighted_metric!=@metric %>
<tr>
<td colspan="<%= @drilldown.columns.size -%>"><%= message('drilldown.drilldown_on') -%>&nbsp;
- <b><%= format_measure(@metric.key, :period => @period) -%> <%= @metric.short_name -%></b></td>
+ <% if @committer %>
+ <b><%= format_measure(@snapshot.committer_measure(@metric, @committer), :period => @period) -%> <%= @metric.short_name -%></b>
+ <% else %>
+ <b><%= format_measure(@metric.key, :period => @period) -%> <%= @metric.short_name -%></b>
+ <% end %>
+ </td>
</tr>
<tr>
<% end