diff --git a/plugins/mezuro/controllers/profile/mezuro_plugin_module_result_controller.rb b/plugins/mezuro/controllers/profile/mezuro_plugin_module_result_controller.rb index 6ea4e28..e28aa92 100644 --- a/plugins/mezuro/controllers/profile/mezuro_plugin_module_result_controller.rb +++ b/plugins/mezuro/controllers/profile/mezuro_plugin_module_result_controller.rb @@ -4,15 +4,10 @@ class MezuroPluginModuleResultController < MezuroPluginProfileController def module_result @module_result = Kalibro::ModuleResult.find(params[:module_result_id].to_i) + @metric_results = Kalibro::MetricResult.metric_results_of(@module_result.id) render :partial => 'module_result' end - def metric_results - @module_result_id = params[:module_result_id].to_i - @metric_results = Kalibro::MetricResult.metric_results_of(@module_result_id) - render :partial => 'metric_results' - end - def metric_result_history @history = Kalibro::MetricResult.history_of(params[:metric_name], params[:module_result_id].to_i) render :partial => 'score_history' diff --git a/plugins/mezuro/lib/kalibro/date_metric_result.rb b/plugins/mezuro/lib/kalibro/date_metric_result.rb index 2254c32..5e79a89 100644 --- a/plugins/mezuro/lib/kalibro/date_metric_result.rb +++ b/plugins/mezuro/lib/kalibro/date_metric_result.rb @@ -9,5 +9,8 @@ class Kalibro::DateMetricResult < Kalibro::Model def metric_result=(value) @metric_result = Kalibro::MetricResult.to_object value end - + + def result + @metric_result.value + end end diff --git a/plugins/mezuro/lib/kalibro/date_module_result.rb b/plugins/mezuro/lib/kalibro/date_module_result.rb index 09a66da..241e7f6 100644 --- a/plugins/mezuro/lib/kalibro/date_module_result.rb +++ b/plugins/mezuro/lib/kalibro/date_module_result.rb @@ -10,4 +10,8 @@ class Kalibro::DateModuleResult < Kalibro::Model @module_result = Kalibro::ModuleResult.to_object value end + def result + @module_result.grade + end + end diff --git a/plugins/mezuro/lib/mezuro_plugin/helpers/content_viewer_helper.rb b/plugins/mezuro/lib/mezuro_plugin/helpers/content_viewer_helper.rb index 0ed41b3..feab0f9 100644 --- a/plugins/mezuro/lib/mezuro_plugin/helpers/content_viewer_helper.rb +++ b/plugins/mezuro/lib/mezuro_plugin/helpers/content_viewer_helper.rb @@ -26,8 +26,8 @@ class MezuroPlugin::Helpers::ContentViewerHelper values = [] labels = [] score_history.each do |score_data| - values << score_data.first - labels << score_data.last + values << score_data.result + labels << score_data.date end labels = discretize_array labels Gchart.line( diff --git a/plugins/mezuro/test/fixtures/metric_configuration_snapshot_fixtures.rb b/plugins/mezuro/test/fixtures/metric_configuration_snapshot_fixtures.rb index 832643e..8494fe1 100644 --- a/plugins/mezuro/test/fixtures/metric_configuration_snapshot_fixtures.rb +++ b/plugins/mezuro/test/fixtures/metric_configuration_snapshot_fixtures.rb @@ -14,7 +14,7 @@ class MetricConfigurationSnapshotFixtures :aggregation_form => 'AVERAGE', :metric => MetricFixtures.amloc_hash, :base_tool_name => "Analizo", - :range => [RangeSnapshotFixtures.range_snapshot_hash], + :range => RangeSnapshotFixtures.range_snapshot_hash, :attributes! => { :metric => { 'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance', @@ -34,7 +34,7 @@ class MetricConfigurationSnapshotFixtures :aggregation_form => 'AVERAGE', :metric => MetricFixtures.compound_metric, :base_tool_name => "Analizo", - :range => [RangeSnapshotFixtures.range_snapshot_hash], + :range => RangeSnapshotFixtures.range_snapshot_hash, :attributes! => { :metric => { 'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance', diff --git a/plugins/mezuro/test/functional/profile/mezuro_plugin_module_result_controller_test.rb b/plugins/mezuro/test/functional/profile/mezuro_plugin_module_result_controller_test.rb index a545a38..cec91e7 100644 --- a/plugins/mezuro/test/functional/profile/mezuro_plugin_module_result_controller_test.rb +++ b/plugins/mezuro/test/functional/profile/mezuro_plugin_module_result_controller_test.rb @@ -22,18 +22,11 @@ class MezuroPluginModuleResultControllerTest < ActionController::TestCase should 'find module result on kalibro' do Kalibro::ModuleResult.expects(:request).with(:get_module_result, { :module_result_id => @module_result_hash[:id] }). returns({:module_result => @module_result_hash}) - get :module_result, :profile => @profile.identifier, :module_result_id => @module_result_hash[:id] - assert_equal @module_result_hash[:grade], assigns(:module_result).grade - assert_response 200 - #TODO assert_select('h5', 'Metric results for: Qt-Calculator (APPLICATION)') - end - - should 'get metric_results' do Kalibro::MetricResult.expects(:request).with(:metric_results_of, { :module_result_id => @module_result_hash[:id] }). returns({:metric_result => @metric_result_hash}) - get :metric_results, :profile => @profile.identifier, :module_result_id => @module_result_hash[:id] + get :module_result, :profile => @profile.identifier, :module_result_id => @module_result_hash[:id] + assert_equal @module_result_hash[:grade], assigns(:module_result).grade assert_equal @metric_result_hash[:value], assigns(:metric_results).first.value - assert_equal @module_result_hash[:id], assigns(:module_result_id) assert_response 200 #TODO assert_select('h5', 'Metric results for: Qt-Calculator (APPLICATION)') end @@ -43,7 +36,7 @@ class MezuroPluginModuleResultControllerTest < ActionController::TestCase Kalibro::MetricResult.expects(:request).with(:history_of, { :metric_name => metric_name, :module_result_id => @module_result_hash[:id] }). returns({:date_metric_result => @date_metric_result_hash}) get :metric_result_history, :profile => @profile.identifier, :module_result_id => @module_result_hash[:id], :metric_name => metric_name - assert_equal @date_metric_result_hash[:date], assigns(:date_metric_results).first.date + assert_equal DateTime.parse(@date_metric_result_hash[:date]), assigns(:history).first.date assert_response 200 #TODO assert_select end @@ -52,7 +45,7 @@ class MezuroPluginModuleResultControllerTest < ActionController::TestCase Kalibro::ModuleResult.expects(:request).with(:history_of_module, { :module_result_id => @module_result_hash[:id] }). returns({:date_module_result => @date_module_result_hash}) get :module_result_history, :profile => @profile.identifier, :module_result_id => @module_result_hash[:id] - assert_equal @date_module_result_hash[:date], assigns(:date_module_results).first.date + assert_equal DateTime.parse(@date_module_result_hash[:date]), assigns(:history).first.date assert_response 200 #TODO assert_select end diff --git a/plugins/mezuro/views/mezuro_plugin_module_result/_metric_results.rhtml b/plugins/mezuro/views/mezuro_plugin_module_result/_metric_results.rhtml new file mode 100644 index 0000000..41e2410 --- /dev/null +++ b/plugins/mezuro/views/mezuro_plugin_module_result/_metric_results.rhtml @@ -0,0 +1,36 @@ + + + Metric + Value + Weight + Threshold + + + + <% @metric_results.each do |metric_result| %> + <% metric_configuration_snapshot = metric_result.metric_configuration_snapshot%> + <% range_snapshot = metric_configuration_snapshot.range_snapshot %> + <% formatted_name = MezuroPlugin::Helpers::ContentViewerHelper.format_name(metric_configuration_snapshot) %> + <% if !range_snapshot.nil? %> + + <%= metric_configuration_snapshot.metric.name %> + <%= MezuroPlugin::Helpers::ContentViewerHelper.format_grade(metric_result.value) %> + <%= metric_configuration_snapshot.weight %> + + + <%= range_snapshot.label %> + + + + + +
+
+ + + <%= range_snapshot.comments.nil? ? '' : range_snapshot.comments %> + + + <% end %> + <% end %> + diff --git a/plugins/mezuro/views/mezuro_plugin_module_result/_module_result.rhtml b/plugins/mezuro/views/mezuro_plugin_module_result/_module_result.rhtml index 790779b..0caa93c 100644 --- a/plugins/mezuro/views/mezuro_plugin_module_result/_module_result.rhtml +++ b/plugins/mezuro/views/mezuro_plugin_module_result/_module_result.rhtml @@ -1,52 +1,17 @@ -<% module_name = @module_result.module.name -
<%= _('Metric results for: #{module_name} (#{@module_result.module.granularity}) ') %>
+<% TODO source tree %> +
<%= _('Metric results for: #{@module_result.module.name} (#{@module_result.module.granularity}) ') %>

- - - - - - - - - - <% @metric_results.each do |metric_result| %> - <% metric_configuration_snapshot = metric_result.metric_configuration_snapshot%> - <% range_snapshot = metric_configuration_snapshot.range_snapshot %> - <% formatted_name = MezuroPlugin::Helpers::ContentViewerHelper.format_name(metric_configuration_snapshot) %> - <% if !range_snapshot.nil? %> - - - - - - - - - - - <% end %> - <% end %> - + <%= render :partial => "metric_results", :locals => {:metric_results => @metric_results, :module_result_id => @module_result.id} %>
MetricValueWeightThreshold
<%= metric_configuration_snapshot.metric.name %><%= MezuroPlugin::Helpers::ContentViewerHelper.format_grade(metric_result.value) %><%= metric_configuration_snapshot.weight %> - - <%= range_snapshot.label %> - -
- + <%= _('Grade:') %> <%= "%.02f" % @module_result.grade %> diff --git a/plugins/mezuro/views/mezuro_plugin_module_result/_score_history.rhtml b/plugins/mezuro/views/mezuro_plugin_module_result/_score_history.rhtml index 9ca66f4..b30fc6a 100644 --- a/plugins/mezuro/views/mezuro_plugin_module_result/_score_history.rhtml +++ b/plugins/mezuro/views/mezuro_plugin_module_result/_score_history.rhtml @@ -1 +1 @@ -<%= image_tag(MezuroPlugin::Helpers::ContentViewerHelper.generate_chart(@score_history)) %> +<%= image_tag(MezuroPlugin::Helpers::ContentViewerHelper.generate_chart(@history)) %> diff --git a/plugins/mezuro/views/mezuro_plugin_module_result/_source_tree.rhtml b/plugins/mezuro/views/mezuro_plugin_module_result/_source_tree.rhtml index 8c7b315..cd4b8d4 100644 --- a/plugins/mezuro/views/mezuro_plugin_module_result/_source_tree.rhtml +++ b/plugins/mezuro/views/mezuro_plugin_module_result/_source_tree.rhtml @@ -1,45 +1,41 @@ -<% unless @content.errors[:base].nil? %> - <%= @content.errors[:base] %> -<% else %> -

<%= _('Source tree') %>

- <% module_name = @source_tree.module.name %> - <% module_label = "#{module_name} (#{@source_tree.module.granularity})" %> +

<%= _('Source tree') %>

+<% module_name = @source_tree.module.name %> +<% module_label = "#{module_name} (#{@source_tree.module.granularity})" %> -

- <% if module_name != @project_name %> - - <%= @project_name %> - - <% end %> +

+ <% if module_name != @project_name %> + + <%= @project_name %> + + <% end %> - <% split_link = @source_tree.module.ancestor_names %> - <% split_link.each do |link| %> - / - <%= link.split(".").last %> - - <% end %> -

- - <% if @source_tree.children %> - - <% @source_tree.children.each do |child| %> - <% if child.module.granularity=='PACKAGE' %> - - - - - <% else %> - - - - - <% end %> - <% end %> -
<%= image_tag('/plugins/mezuro/images/folder.png')%><%= child.module.name %>
<%= image_tag('/plugins/mezuro/images/file.png') %> - - <%= child.module.name %> - -
+ <% split_link = @source_tree.module.ancestor_names %> + <% split_link.each do |link| %> + / + <%= link.split(".").last %> + <% end %> +

+ +<% if @source_tree.children %> + + <% @source_tree.children.each do |child| %> + <% if child.module.granularity=='PACKAGE' %> + + + + + <% else %> + + + + + <% end %> + <% end %> +
<%= image_tag('/plugins/mezuro/images/folder.png')%><%= child.module.name %>
<%= image_tag('/plugins/mezuro/images/file.png') %> + + <%= child.module.name %> + +
<% end %> -- libgit2 0.21.2