Commit 8d65ed4d6e57be14a42cd70583fb62c2866e1a2a
1 parent
c7828da0
Exists in
colab
and in
4 other branches
Separate hotspot from tree metric on configurations show
Signed off by: Eduardo Silva Araújo <duduktamg@hotmail.com> Signed off by: Diego Araújo <diegoamc90@gmail.com>
Showing
6 changed files
with
50 additions
and
11 deletions
Show diff stats
app/controllers/kalibro_configurations_controller.rb
... | ... | @@ -28,8 +28,11 @@ class KalibroConfigurationsController < ApplicationController |
28 | 28 | # GET /kalibro_configurations/1 |
29 | 29 | # GET /kalibro_configurations/1.json |
30 | 30 | def show |
31 | - Rails.cache.fetch("#{@kalibro_configuration.id}_metric_configurations") do | |
32 | - @kalibro_configuration.metric_configurations | |
31 | + Rails.cache.fetch("#{@kalibro_configuration.id}_tree_metric_configurations") do | |
32 | + @kalibro_configuration.tree_metric_configurations | |
33 | + end | |
34 | + Rails.cache.fetch("#{@kalibro_configuration.id}_hotspot_metric_configurations") do | |
35 | + @kalibro_configuration.hotspot_metric_configurations | |
33 | 36 | end |
34 | 37 | end |
35 | 38 | ... | ... |
app/controllers/metric_configurations_controller.rb
... | ... | @@ -20,7 +20,7 @@ class MetricConfigurationsController < BaseMetricConfigurationsController |
20 | 20 | respond_to do |format| |
21 | 21 | create_and_redir(format) |
22 | 22 | end |
23 | - Rails.cache.delete("#{params[:kalibro_configuration_id]}_metric_configurations") | |
23 | + update_caches | |
24 | 24 | end |
25 | 25 | |
26 | 26 | def edit |
... | ... | @@ -38,7 +38,7 @@ class MetricConfigurationsController < BaseMetricConfigurationsController |
38 | 38 | if @metric_configuration.update(metric_configuration_params) |
39 | 39 | format.html { redirect_to(kalibro_configuration_path(@metric_configuration.kalibro_configuration_id), notice: t('successfully_updated', :record => t(metric_configuration.class))) } |
40 | 40 | format.json { head :no_content } |
41 | - Rails.cache.delete("#{@metric_configuration.kalibro_configuration_id}_metric_configurations") | |
41 | + update_caches | |
42 | 42 | else |
43 | 43 | failed_action(format, 'edit') |
44 | 44 | end |
... | ... | @@ -51,7 +51,7 @@ class MetricConfigurationsController < BaseMetricConfigurationsController |
51 | 51 | format.html { redirect_to kalibro_configuration_path(params[:kalibro_configuration_id]) } |
52 | 52 | format.json { head :no_content } |
53 | 53 | end |
54 | - Rails.cache.delete("#{params[:kalibro_configuration_id]}_metric_configurations") | |
54 | + update_caches | |
55 | 55 | end |
56 | 56 | |
57 | 57 | protected |
... | ... | @@ -67,6 +67,11 @@ class MetricConfigurationsController < BaseMetricConfigurationsController |
67 | 67 | |
68 | 68 | private |
69 | 69 | |
70 | + def update_caches | |
71 | + Rails.cache.delete("#{params[:kalibro_configuration_id]}_tree_metric_configurations") | |
72 | + Rails.cache.delete("#{params[:kalibro_configuration_id]}_hotspot_metric_configurations") | |
73 | + end | |
74 | + | |
70 | 75 | # Duplicated code on create and update actions extracted here |
71 | 76 | def failed_action(format, destiny_action) |
72 | 77 | @kalibro_configuration_id = params[:kalibro_configuration_id] | ... | ... |
app/views/kalibro_configurations/_metric_configurations.html.erb
1 | 1 | <tr> |
2 | 2 | <td><%= metric_configuration.metric.name %></td> |
3 | - <td><%= metric_configuration.metric.code %></td> | |
4 | - <td><%= metric_configuration.weight %></td> | |
3 | + <% unless metric_configuration.metric.is_a? KalibroClient::Entities::Miscellaneous::HotspotMetric %> | |
4 | + <td><%= metric_configuration.metric.code %></td> | |
5 | + <td><%= metric_configuration.weight %></td> | |
6 | + <% end %> | |
5 | 7 | <td> |
6 | 8 | <%= link_to_show_page(metric_configuration, @kalibro_configuration.id) %> |
7 | 9 | </td> | ... | ... |
app/views/kalibro_configurations/show.html.erb
... | ... | @@ -8,11 +8,11 @@ |
8 | 8 | </p> |
9 | 9 | |
10 | 10 | <hr> |
11 | -<div id="metrics"> | |
12 | -<h2><%= t('metric').pluralize %></h2> | |
13 | 11 | <% if kalibro_configuration_owner? @kalibro_configuration.id %> |
14 | 12 | <%= link_to t_action(:add, MetricConfiguration), kalibro_configuration_choose_metric_path(@kalibro_configuration.id), class: 'btn btn-info' %> |
15 | 13 | <% end %> |
14 | +<div id="tree_metrics"> | |
15 | +<h2><%= t('tree_metric').pluralize %></h2> | |
16 | 16 | |
17 | 17 | <table class="table table-hover"> |
18 | 18 | <thead> |
... | ... | @@ -24,10 +24,10 @@ |
24 | 24 | </tr> |
25 | 25 | </thead> |
26 | 26 | <tbody> |
27 | - <% if Rails.cache.read("#{@kalibro_configuration.id}_metric_configurations").empty? %> | |
27 | + <% if Rails.cache.read("#{@kalibro_configuration.id}_tree_metric_configurations").empty? %> | |
28 | 28 | <%= render partial: 'no_metric_configurations' %> |
29 | 29 | <% else %> |
30 | - <%= render partial: 'metric_configurations', collection: Rails.cache.read("#{@kalibro_configuration.id}_metric_configurations"), as: :metric_configuration %> | |
30 | + <%= render partial: 'metric_configurations', collection: Rails.cache.read("#{@kalibro_configuration.id}_tree_metric_configurations"), as: :metric_configuration %> | |
31 | 31 | <% end %> |
32 | 32 | </tbody> |
33 | 33 | </table> |
... | ... | @@ -35,6 +35,27 @@ |
35 | 35 | |
36 | 36 | <hr> |
37 | 37 | |
38 | +<div id="hotspot_metrics"> | |
39 | +<h2><%= t('hotspot_metric').pluralize %></h2> | |
40 | + | |
41 | +<table class="table table-hover"> | |
42 | + <thead> | |
43 | + <tr> | |
44 | + <th><%= t('metric') %></th> | |
45 | + <th colspan="1"></th> | |
46 | + </tr> | |
47 | + </thead> | |
48 | + <tbody> | |
49 | + <% if Rails.cache.read("#{@kalibro_configuration.id}_hotspot_metric_configurations").empty? %> | |
50 | + <%= render partial: 'no_metric_configurations' %> | |
51 | + <% else %> | |
52 | + <%= render partial: 'metric_configurations', collection: Rails.cache.read("#{@kalibro_configuration.id}_hotspot_metric_configurations"), as: :metric_configuration %> | |
53 | + <% end %> | |
54 | + </tbody> | |
55 | +</table> | |
56 | +</div> | |
57 | + | |
58 | +<hr> | |
38 | 59 | <p> |
39 | 60 | <%= link_to t('back'), kalibro_configurations_path, class: 'btn btn-default' %> |
40 | 61 | <% if kalibro_configuration_owner? @kalibro_configuration.id %> | ... | ... |
config/locales/views/en.yml
... | ... | @@ -47,6 +47,10 @@ en: |
47 | 47 | no_description: "There is no description available" |
48 | 48 | welcome: "Welcome" |
49 | 49 | metrics: "Metrics" |
50 | + tree_metrics: "Tree Metrics" | |
51 | + tree_metric: "Tree Metric" | |
52 | + hotspot_metrics: "Hotspot Metrics" | |
53 | + hotspot_metric: "Hotspot Metric" | |
50 | 54 | value: "Value" |
51 | 55 | threshold: "Threshold" |
52 | 56 | granularity: "Granularity" | ... | ... |
config/locales/views/pt.yml
... | ... | @@ -50,6 +50,10 @@ pt: |
50 | 50 | no_description: "Não há descrição disponível." |
51 | 51 | welcome: "Bem-Vindo" |
52 | 52 | metrics: "Métricas" |
53 | + tree_metrics: "Métricas escalares" | |
54 | + tree_metric: "Métrica escalar" | |
55 | + hotspot_metrics: "Métricas de Hotspot" | |
56 | + hotspot_metric: "Métrica de Hotspot" | |
53 | 57 | value: "Valor" |
54 | 58 | threshold: "limite" |
55 | 59 | granularity: "Granularidade" | ... | ... |