]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-3231 Allow to use committer for measures drilldown
authorEvgeny Mandrikov <mandrikov@gmail.com>
Tue, 7 Feb 2012 13:49:10 +0000 (17:49 +0400)
committerEvgeny Mandrikov <mandrikov@gmail.com>
Tue, 7 Feb 2012 14:38:20 +0000 (18:38 +0400)
sonar-server/src/main/webapp/WEB-INF/app/controllers/drilldown_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/models/drilldown.rb
sonar-server/src/main/webapp/WEB-INF/app/models/snapshot.rb
sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/measures.html.erb

index 58fca07c79569f44508026cd908e34183b40de6b..700160f9df27ae9a432209b3506aa2060f7ec49b 100644 (file)
@@ -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
index c198930fe3cf8df88e8497cede9655d827e6c6a6..c6c4198a4c18b0f1d4855fa5001fe40ed10fbcf7 100644 (file)
@@ -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",
index e840b1665e301e13628ca55d6339bdad8e045285..872efacc4809cb9824068eac70074eef0cb0df34 100644 (file)
@@ -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
index 979ede257649776ff9d9ad9cdc2b539f06d90195..4542b0651d10317459521f88e8838c9261ade1f4 100644 (file)
 <% 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>
   <% 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