Commit 473eb6cc4e3abb900fd486ddf3b503635e1b9771

Authored by Guilherme Rojas V. de Lima
Committed by Rafael Manzo
1 parent ec966f57

Created method to get a list of metric grades

Added some modifications in views to support the pending action call.
Signed-off By: Fellipe Souto <fllsouto@gmail.com>
Signed-off By: Renan Fichberg <rfichberg@gmail.com>
app/models/date_module_result.rb 0 → 100644
@@ -0,0 +1,8 @@ @@ -0,0 +1,8 @@
  1 +class DateModuleResult < KalibroEntities::Entities::DateModuleResult
  2 + include KalibroRecord
  3 +
  4 + def module_result
  5 + ModuleResult.new @module_result.to_hash
  6 + end
  7 +
  8 +end
0 \ No newline at end of file 9 \ No newline at end of file
app/models/module_result.rb
@@ -4,4 +4,25 @@ class ModuleResult &lt; KalibroEntities::Entities::ModuleResult @@ -4,4 +4,25 @@ class ModuleResult &lt; KalibroEntities::Entities::ModuleResult
4 def metric_results 4 def metric_results
5 KalibroEntities::Entities::MetricResult.metric_results_of(@id) 5 KalibroEntities::Entities::MetricResult.metric_results_of(@id)
6 end 6 end
  7 +
  8 + def history_of()
  9 + KalibroEntities::Entities::ModuleResult.history_of(@id).map { |date_module_result| DateModuleResult.new date_module_result.to_hash }
  10 + end
  11 +
  12 + def history_of_grades_of(metric_name)
  13 + history_of_grades = Hash.new
  14 +
  15 + date_module_result_list = history_of(@id)
  16 + date_module_result_list.each do |date_module_result|
  17 + date_module_result.module_result.metric_results.each do |metric_result|
  18 + if metric_result.metric_configuration_snapshot.metric.name == metric_name then
  19 + metric_grade = metric_result.metric_configuration_snapshot.grade
  20 + break
  21 + end
  22 + end
  23 + history_of_grades[date_module_result.date] = metric_grade
  24 + end
  25 + history_of_grades
  26 + end
  27 +
7 end 28 end
8 \ No newline at end of file 29 \ No newline at end of file
app/views/repositories/_metric_result.html.erb
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 <% unless metric_configuration_snapshot.range_snapshot.nil? %> 2 <% unless metric_configuration_snapshot.range_snapshot.nil? %>
3 <% range_snapshot = find_range_snapshot(metric_result) %> 3 <% range_snapshot = find_range_snapshot(metric_result) %>
4 <tr> 4 <tr>
5 - <td><%= metric_configuration_snapshot.metric.name %></td> 5 + <td><%= link_to metric_configuration_snapshot.metric.name %></td>
6 <td><%= format_grade(metric_result.value) %></td> 6 <td><%= format_grade(metric_result.value) %></td>
7 <td><%= metric_configuration_snapshot.weight %></td> 7 <td><%= metric_configuration_snapshot.weight %></td>
8 <td><span style="color: #<%= range_snapshot.color %>"><%= range_snapshot.label %></span></td> 8 <td><span style="color: #<%= range_snapshot.color %>"><%= range_snapshot.label %></span></td>
app/views/repositories/show.html.erb
@@ -67,7 +67,6 @@ @@ -67,7 +67,6 @@
67 </tbody> 67 </tbody>
68 </table> 68 </table>
69 <% end %> 69 <% end %>
70 -  
71 <hr/> 70 <hr/>
72 71
73 <h2>Metric Results</h2> 72 <h2>Metric Results</h2>
@@ -80,7 +79,7 @@ @@ -80,7 +79,7 @@
80 </thead> 79 </thead>
81 80
82 <tbody> 81 <tbody>
83 - <%= render partial: 'metric_result', collection: @root_module_result.metric_results %> 82 + <%= render partial: 'metric_result', collection: @root_module_result.metric_results, locals: {module_result: @root_module_result} %>
84 </tbody> 83 </tbody>
85 84
86 </table> 85 </table>