Commit 782f5a15849257865cdd1f03cab44160aacbd8ab
Committed by
João M. M. da Silva
1 parent
b18ed7d2
Exists in
master
and in
29 other branches
[Mezuro] fixed history view, finished module_result view and metric_results view
Showing
10 changed files
with
94 additions
and
102 deletions
Show diff stats
plugins/mezuro/controllers/profile/mezuro_plugin_module_result_controller.rb
... | ... | @@ -4,15 +4,10 @@ class MezuroPluginModuleResultController < MezuroPluginProfileController |
4 | 4 | |
5 | 5 | def module_result |
6 | 6 | @module_result = Kalibro::ModuleResult.find(params[:module_result_id].to_i) |
7 | + @metric_results = Kalibro::MetricResult.metric_results_of(@module_result.id) | |
7 | 8 | render :partial => 'module_result' |
8 | 9 | end |
9 | 10 | |
10 | - def metric_results | |
11 | - @module_result_id = params[:module_result_id].to_i | |
12 | - @metric_results = Kalibro::MetricResult.metric_results_of(@module_result_id) | |
13 | - render :partial => 'metric_results' | |
14 | - end | |
15 | - | |
16 | 11 | def metric_result_history |
17 | 12 | @history = Kalibro::MetricResult.history_of(params[:metric_name], params[:module_result_id].to_i) |
18 | 13 | render :partial => 'score_history' | ... | ... |
plugins/mezuro/lib/kalibro/date_metric_result.rb
plugins/mezuro/lib/kalibro/date_module_result.rb
plugins/mezuro/lib/mezuro_plugin/helpers/content_viewer_helper.rb
... | ... | @@ -26,8 +26,8 @@ class MezuroPlugin::Helpers::ContentViewerHelper |
26 | 26 | values = [] |
27 | 27 | labels = [] |
28 | 28 | score_history.each do |score_data| |
29 | - values << score_data.first | |
30 | - labels << score_data.last | |
29 | + values << score_data.result | |
30 | + labels << score_data.date | |
31 | 31 | end |
32 | 32 | labels = discretize_array labels |
33 | 33 | Gchart.line( | ... | ... |
plugins/mezuro/test/fixtures/metric_configuration_snapshot_fixtures.rb
... | ... | @@ -14,7 +14,7 @@ class MetricConfigurationSnapshotFixtures |
14 | 14 | :aggregation_form => 'AVERAGE', |
15 | 15 | :metric => MetricFixtures.amloc_hash, |
16 | 16 | :base_tool_name => "Analizo", |
17 | - :range => [RangeSnapshotFixtures.range_snapshot_hash], | |
17 | + :range => RangeSnapshotFixtures.range_snapshot_hash, | |
18 | 18 | :attributes! => { |
19 | 19 | :metric => { |
20 | 20 | 'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance', |
... | ... | @@ -34,7 +34,7 @@ class MetricConfigurationSnapshotFixtures |
34 | 34 | :aggregation_form => 'AVERAGE', |
35 | 35 | :metric => MetricFixtures.compound_metric, |
36 | 36 | :base_tool_name => "Analizo", |
37 | - :range => [RangeSnapshotFixtures.range_snapshot_hash], | |
37 | + :range => RangeSnapshotFixtures.range_snapshot_hash, | |
38 | 38 | :attributes! => { |
39 | 39 | :metric => { |
40 | 40 | 'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance', | ... | ... |
plugins/mezuro/test/functional/profile/mezuro_plugin_module_result_controller_test.rb
... | ... | @@ -22,18 +22,11 @@ class MezuroPluginModuleResultControllerTest < ActionController::TestCase |
22 | 22 | should 'find module result on kalibro' do |
23 | 23 | Kalibro::ModuleResult.expects(:request).with(:get_module_result, { :module_result_id => @module_result_hash[:id] }). |
24 | 24 | returns({:module_result => @module_result_hash}) |
25 | - get :module_result, :profile => @profile.identifier, :module_result_id => @module_result_hash[:id] | |
26 | - assert_equal @module_result_hash[:grade], assigns(:module_result).grade | |
27 | - assert_response 200 | |
28 | - #TODO assert_select('h5', 'Metric results for: Qt-Calculator (APPLICATION)') | |
29 | - end | |
30 | - | |
31 | - should 'get metric_results' do | |
32 | 25 | Kalibro::MetricResult.expects(:request).with(:metric_results_of, { :module_result_id => @module_result_hash[:id] }). |
33 | 26 | returns({:metric_result => @metric_result_hash}) |
34 | - get :metric_results, :profile => @profile.identifier, :module_result_id => @module_result_hash[:id] | |
27 | + get :module_result, :profile => @profile.identifier, :module_result_id => @module_result_hash[:id] | |
28 | + assert_equal @module_result_hash[:grade], assigns(:module_result).grade | |
35 | 29 | assert_equal @metric_result_hash[:value], assigns(:metric_results).first.value |
36 | - assert_equal @module_result_hash[:id], assigns(:module_result_id) | |
37 | 30 | assert_response 200 |
38 | 31 | #TODO assert_select('h5', 'Metric results for: Qt-Calculator (APPLICATION)') |
39 | 32 | end |
... | ... | @@ -43,7 +36,7 @@ class MezuroPluginModuleResultControllerTest < ActionController::TestCase |
43 | 36 | Kalibro::MetricResult.expects(:request).with(:history_of, { :metric_name => metric_name, :module_result_id => @module_result_hash[:id] }). |
44 | 37 | returns({:date_metric_result => @date_metric_result_hash}) |
45 | 38 | get :metric_result_history, :profile => @profile.identifier, :module_result_id => @module_result_hash[:id], :metric_name => metric_name |
46 | - assert_equal @date_metric_result_hash[:date], assigns(:date_metric_results).first.date | |
39 | + assert_equal DateTime.parse(@date_metric_result_hash[:date]), assigns(:history).first.date | |
47 | 40 | assert_response 200 |
48 | 41 | #TODO assert_select |
49 | 42 | end |
... | ... | @@ -52,7 +45,7 @@ class MezuroPluginModuleResultControllerTest < ActionController::TestCase |
52 | 45 | Kalibro::ModuleResult.expects(:request).with(:history_of_module, { :module_result_id => @module_result_hash[:id] }). |
53 | 46 | returns({:date_module_result => @date_module_result_hash}) |
54 | 47 | get :module_result_history, :profile => @profile.identifier, :module_result_id => @module_result_hash[:id] |
55 | - assert_equal @date_module_result_hash[:date], assigns(:date_module_results).first.date | |
48 | + assert_equal DateTime.parse(@date_module_result_hash[:date]), assigns(:history).first.date | |
56 | 49 | assert_response 200 |
57 | 50 | #TODO assert_select |
58 | 51 | end | ... | ... |
plugins/mezuro/views/mezuro_plugin_module_result/_metric_results.rhtml
0 → 100644
... | ... | @@ -0,0 +1,36 @@ |
1 | +<thead> | |
2 | + <tr> | |
3 | + <th style="width: 74%">Metric</th> | |
4 | + <th>Value</th> | |
5 | + <th>Weight</th> | |
6 | + <th>Threshold</th> | |
7 | + </tr> | |
8 | +</thead> | |
9 | +<tbody> | |
10 | + <% @metric_results.each do |metric_result| %> | |
11 | + <% metric_configuration_snapshot = metric_result.metric_configuration_snapshot%> | |
12 | + <% range_snapshot = metric_configuration_snapshot.range_snapshot %> | |
13 | + <% formatted_name = MezuroPlugin::Helpers::ContentViewerHelper.format_name(metric_configuration_snapshot) %> | |
14 | + <% if !range_snapshot.nil? %> | |
15 | + <tr> | |
16 | + <td style="width: 74%"><a href="#" show-metric-history="<%= formatted_name %>" data-module-id="<%= @module_result_id %>"><%= metric_configuration_snapshot.metric.name %></a></td> | |
17 | + <td><%= MezuroPlugin::Helpers::ContentViewerHelper.format_grade(metric_result.value) %></td> | |
18 | + <td><%= metric_configuration_snapshot.weight %></td> | |
19 | + <td style="background-color: #<%= range_snapshot.color %>"> | |
20 | + <span title="<%= range_snapshot.comments %>" > | |
21 | + <%= range_snapshot.label %> | |
22 | + </span> | |
23 | + </td> | |
24 | + </tr> | |
25 | + <tr class="<%= formatted_name %>" style="display: none;"> | |
26 | + <td colspan="3"> | |
27 | + <div id='historical-<%= formatted_name %>'> | |
28 | + </div> | |
29 | + </td> | |
30 | + <td align="right"> | |
31 | + <%= range_snapshot.comments.nil? ? '' : range_snapshot.comments %> | |
32 | + </td> | |
33 | + </tr> | |
34 | + <% end %> | |
35 | + <% end %> | |
36 | +</tbody> | ... | ... |
plugins/mezuro/views/mezuro_plugin_module_result/_module_result.rhtml
1 | -<% module_name = @module_result.module.name | |
2 | -<h5><%= _('Metric results for: #{module_name} (#{@module_result.module.granularity}) ') %> </h5> | |
1 | +<% TODO source tree %> | |
2 | +<h5><%= _('Metric results for: #{@module_result.module.name} (#{@module_result.module.granularity}) ') %> </h5> | |
3 | 3 | |
4 | 4 | <hr/> |
5 | 5 | <div class="zoomable-image"> |
6 | 6 | <table style="width: 100%"> |
7 | - <thead> | |
8 | - <tr> | |
9 | - <th style="width: 74%">Metric</th> | |
10 | - <th>Value</th> | |
11 | - <th>Weight</th> | |
12 | - <th>Threshold</th> | |
13 | - </tr> | |
14 | - </thead> | |
15 | - <tbody> | |
16 | - <% @metric_results.each do |metric_result| %> | |
17 | - <% metric_configuration_snapshot = metric_result.metric_configuration_snapshot%> | |
18 | - <% range_snapshot = metric_configuration_snapshot.range_snapshot %> | |
19 | - <% formatted_name = MezuroPlugin::Helpers::ContentViewerHelper.format_name(metric_configuration_snapshot) %> | |
20 | - <% if !range_snapshot.nil? %> | |
21 | - <tr> | |
22 | - <td style="width: 74%"><a href="#" show-metric-history="<%= formatted_name %>" data-module-name="<%= module_name %>"><%= metric_configuration_snapshot.metric.name %></a></td> | |
23 | - <td><%= MezuroPlugin::Helpers::ContentViewerHelper.format_grade(metric_result.value) %></td> | |
24 | - <td><%= metric_configuration_snapshot.weight %></td> | |
25 | - <td style="background-color: #<%= range_snapshot.color %>"> | |
26 | - <span title="<%= range_snapshot.comments %>" > | |
27 | - <%= range_snapshot.label %> | |
28 | - </span> | |
29 | - </td> | |
30 | - </tr> | |
31 | - <tr class="<%= formatted_name %>" style="display: none;"> | |
32 | - <td colspan="3"> | |
33 | - <div id='historical-<%= formatted_name %>'> | |
34 | - </div> | |
35 | - </td> | |
36 | - <td align="right"> | |
37 | - <%= range_snapshot.comments.nil? ? '' : range_snapshot.comments %> | |
38 | - </td> | |
39 | - </tr> | |
40 | - <% end %> | |
41 | - <% end %> | |
42 | - </tbody> | |
7 | + <%= render :partial => "metric_results", :locals => {:metric_results => @metric_results, :module_result_id => @module_result.id} %> | |
43 | 8 | <tfoot> |
44 | 9 | <tr> |
45 | 10 | <td colspan = "3"> |
46 | 11 | <div id='historical-grade' style="display: none;"></div> |
47 | 12 | </td> |
48 | 13 | <td align = "right"> |
49 | - <a href="#" show-grade-history="<%= module_name %>" data-module-name="<%= module_name%>" > | |
14 | + <a href="#" show-grade-history="<%= @module_result.id %>" data-module-id="<%= module_result.id %>" > | |
50 | 15 | <strong> |
51 | 16 | <%= _('Grade:') %> |
52 | 17 | <%= "%.02f" % @module_result.grade %> | ... | ... |
plugins/mezuro/views/mezuro_plugin_module_result/_score_history.rhtml
plugins/mezuro/views/mezuro_plugin_module_result/_source_tree.rhtml
1 | -<% unless @content.errors[:base].nil? %> | |
2 | - <%= @content.errors[:base] %> | |
3 | -<% else %> | |
4 | - <h4><%= _('Source tree') %></h4> | |
5 | - <% module_name = @source_tree.module.name %> | |
6 | - <% module_label = "#{module_name} (#{@source_tree.module.granularity})" %> | |
1 | +<h4><%= _('Source tree') %></h4> | |
2 | +<% module_name = @source_tree.module.name %> | |
3 | +<% module_label = "#{module_name} (#{@source_tree.module.granularity})" %> | |
7 | 4 | |
8 | - <p><h2 class="path"> | |
9 | - <% if module_name != @project_name %> | |
10 | - <a href="#" class="source-tree-link" data-module-name="<%= @project_name %>"> | |
11 | - <%= @project_name %> | |
12 | - </a> | |
13 | - <% end %> | |
5 | +<p><h2 class="path"> | |
6 | + <% if module_name != @project_name %> | |
7 | + <a href="#" class="source-tree-link" data-module-name="<%= @project_name %>"> | |
8 | + <%= @project_name %> | |
9 | + </a> | |
10 | + <% end %> | |
14 | 11 | |
15 | 12 | |
16 | - <% split_link = @source_tree.module.ancestor_names %> | |
17 | - <% split_link.each do |link| %> | |
18 | - /<a href="#" class="source-tree-link" data-module-name="<%= link %>"> | |
19 | - <%= link.split(".").last %> | |
20 | - </a> | |
21 | - <% end %> | |
22 | - </h2></p> | |
23 | - | |
24 | - <% if @source_tree.children %> | |
25 | - <table border="0" class="source-tree"> | |
26 | - <% @source_tree.children.each do |child| %> | |
27 | - <% if child.module.granularity=='PACKAGE' %> | |
28 | - <tr> | |
29 | - <td class="icon"><%= image_tag('/plugins/mezuro/images/folder.png')%></td> | |
30 | - <td class="source-tree-text"><a href='#' class="source-tree-link" data-module-name="<%= child.module.name %>"><%= child.module.name %></a></td> | |
31 | - </tr> | |
32 | - <% else %> | |
33 | - <tr> | |
34 | - <td class="icon"><%= image_tag('/plugins/mezuro/images/file.png') %></td> | |
35 | - <td class="source-tree-text"> | |
36 | - <a href='#' class="source-tree-link" data-module-name="<%= child.module.name %>"> | |
37 | - <%= child.module.name %> | |
38 | - </a> | |
39 | - </td> | |
40 | - </tr> | |
41 | - <% end %> | |
42 | - <% end %> | |
43 | - </table> | |
13 | + <% split_link = @source_tree.module.ancestor_names %> | |
14 | + <% split_link.each do |link| %> | |
15 | + /<a href="#" class="source-tree-link" data-module-name="<%= link %>"> | |
16 | + <%= link.split(".").last %> | |
17 | + </a> | |
44 | 18 | <% end %> |
19 | +</h2></p> | |
20 | + | |
21 | +<% if @source_tree.children %> | |
22 | + <table border="0" class="source-tree"> | |
23 | + <% @source_tree.children.each do |child| %> | |
24 | + <% if child.module.granularity=='PACKAGE' %> | |
25 | + <tr> | |
26 | + <td class="icon"><%= image_tag('/plugins/mezuro/images/folder.png')%></td> | |
27 | + <td class="source-tree-text"><a href='#' class="source-tree-link" data-module-name="<%= child.module.name %>"><%= child.module.name %></a></td> | |
28 | + </tr> | |
29 | + <% else %> | |
30 | + <tr> | |
31 | + <td class="icon"><%= image_tag('/plugins/mezuro/images/file.png') %></td> | |
32 | + <td class="source-tree-text"> | |
33 | + <a href='#' class="source-tree-link" data-module-name="<%= child.module.name %>"> | |
34 | + <%= child.module.name %> | |
35 | + </a> | |
36 | + </td> | |
37 | + </tr> | |
38 | + <% end %> | |
39 | + <% end %> | |
40 | + </table> | |
45 | 41 | <% end %> | ... | ... |