Commit 473eb6cc4e3abb900fd486ddf3b503635e1b9771
Committed by
Rafael Manzo
1 parent
ec966f57
Exists in
colab
and in
4 other branches
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>
Showing
4 changed files
with
31 additions
and
3 deletions
Show diff stats
app/models/module_result.rb
... | ... | @@ -4,4 +4,25 @@ class ModuleResult < KalibroEntities::Entities::ModuleResult |
4 | 4 | def metric_results |
5 | 5 | KalibroEntities::Entities::MetricResult.metric_results_of(@id) |
6 | 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 | 28 | end |
8 | 29 | \ No newline at end of file | ... | ... |
app/views/repositories/_metric_result.html.erb
... | ... | @@ -2,7 +2,7 @@ |
2 | 2 | <% unless metric_configuration_snapshot.range_snapshot.nil? %> |
3 | 3 | <% range_snapshot = find_range_snapshot(metric_result) %> |
4 | 4 | <tr> |
5 | - <td><%= metric_configuration_snapshot.metric.name %></td> | |
5 | + <td><%= link_to metric_configuration_snapshot.metric.name %></td> | |
6 | 6 | <td><%= format_grade(metric_result.value) %></td> |
7 | 7 | <td><%= metric_configuration_snapshot.weight %></td> |
8 | 8 | <td><span style="color: #<%= range_snapshot.color %>"><%= range_snapshot.label %></span></td> | ... | ... |
app/views/repositories/show.html.erb
... | ... | @@ -67,7 +67,6 @@ |
67 | 67 | </tbody> |
68 | 68 | </table> |
69 | 69 | <% end %> |
70 | - | |
71 | 70 | <hr/> |
72 | 71 | |
73 | 72 | <h2>Metric Results</h2> |
... | ... | @@ -80,7 +79,7 @@ |
80 | 79 | </thead> |
81 | 80 | |
82 | 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 | 83 | </tbody> |
85 | 84 | |
86 | 85 | </table> | ... | ... |