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,8 +28,11 @@ class KalibroConfigurationsController < ApplicationController | ||
| 28 | # GET /kalibro_configurations/1 | 28 | # GET /kalibro_configurations/1 |
| 29 | # GET /kalibro_configurations/1.json | 29 | # GET /kalibro_configurations/1.json |
| 30 | def show | 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 | end | 36 | end |
| 34 | end | 37 | end |
| 35 | 38 |
app/controllers/metric_configurations_controller.rb
| @@ -20,7 +20,7 @@ class MetricConfigurationsController < BaseMetricConfigurationsController | @@ -20,7 +20,7 @@ class MetricConfigurationsController < BaseMetricConfigurationsController | ||
| 20 | respond_to do |format| | 20 | respond_to do |format| |
| 21 | create_and_redir(format) | 21 | create_and_redir(format) |
| 22 | end | 22 | end |
| 23 | - Rails.cache.delete("#{params[:kalibro_configuration_id]}_metric_configurations") | 23 | + update_caches |
| 24 | end | 24 | end |
| 25 | 25 | ||
| 26 | def edit | 26 | def edit |
| @@ -38,7 +38,7 @@ class MetricConfigurationsController < BaseMetricConfigurationsController | @@ -38,7 +38,7 @@ class MetricConfigurationsController < BaseMetricConfigurationsController | ||
| 38 | if @metric_configuration.update(metric_configuration_params) | 38 | if @metric_configuration.update(metric_configuration_params) |
| 39 | format.html { redirect_to(kalibro_configuration_path(@metric_configuration.kalibro_configuration_id), notice: t('successfully_updated', :record => t(metric_configuration.class))) } | 39 | format.html { redirect_to(kalibro_configuration_path(@metric_configuration.kalibro_configuration_id), notice: t('successfully_updated', :record => t(metric_configuration.class))) } |
| 40 | format.json { head :no_content } | 40 | format.json { head :no_content } |
| 41 | - Rails.cache.delete("#{@metric_configuration.kalibro_configuration_id}_metric_configurations") | 41 | + update_caches |
| 42 | else | 42 | else |
| 43 | failed_action(format, 'edit') | 43 | failed_action(format, 'edit') |
| 44 | end | 44 | end |
| @@ -51,7 +51,7 @@ class MetricConfigurationsController < BaseMetricConfigurationsController | @@ -51,7 +51,7 @@ class MetricConfigurationsController < BaseMetricConfigurationsController | ||
| 51 | format.html { redirect_to kalibro_configuration_path(params[:kalibro_configuration_id]) } | 51 | format.html { redirect_to kalibro_configuration_path(params[:kalibro_configuration_id]) } |
| 52 | format.json { head :no_content } | 52 | format.json { head :no_content } |
| 53 | end | 53 | end |
| 54 | - Rails.cache.delete("#{params[:kalibro_configuration_id]}_metric_configurations") | 54 | + update_caches |
| 55 | end | 55 | end |
| 56 | 56 | ||
| 57 | protected | 57 | protected |
| @@ -67,6 +67,11 @@ class MetricConfigurationsController < BaseMetricConfigurationsController | @@ -67,6 +67,11 @@ class MetricConfigurationsController < BaseMetricConfigurationsController | ||
| 67 | 67 | ||
| 68 | private | 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 | # Duplicated code on create and update actions extracted here | 75 | # Duplicated code on create and update actions extracted here |
| 71 | def failed_action(format, destiny_action) | 76 | def failed_action(format, destiny_action) |
| 72 | @kalibro_configuration_id = params[:kalibro_configuration_id] | 77 | @kalibro_configuration_id = params[:kalibro_configuration_id] |
app/views/kalibro_configurations/_metric_configurations.html.erb
| 1 | <tr> | 1 | <tr> |
| 2 | <td><%= metric_configuration.metric.name %></td> | 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 | <td> | 7 | <td> |
| 6 | <%= link_to_show_page(metric_configuration, @kalibro_configuration.id) %> | 8 | <%= link_to_show_page(metric_configuration, @kalibro_configuration.id) %> |
| 7 | </td> | 9 | </td> |
app/views/kalibro_configurations/show.html.erb
| @@ -8,11 +8,11 @@ | @@ -8,11 +8,11 @@ | ||
| 8 | </p> | 8 | </p> |
| 9 | 9 | ||
| 10 | <hr> | 10 | <hr> |
| 11 | -<div id="metrics"> | ||
| 12 | -<h2><%= t('metric').pluralize %></h2> | ||
| 13 | <% if kalibro_configuration_owner? @kalibro_configuration.id %> | 11 | <% if kalibro_configuration_owner? @kalibro_configuration.id %> |
| 14 | <%= link_to t_action(:add, MetricConfiguration), kalibro_configuration_choose_metric_path(@kalibro_configuration.id), class: 'btn btn-info' %> | 12 | <%= link_to t_action(:add, MetricConfiguration), kalibro_configuration_choose_metric_path(@kalibro_configuration.id), class: 'btn btn-info' %> |
| 15 | <% end %> | 13 | <% end %> |
| 14 | +<div id="tree_metrics"> | ||
| 15 | +<h2><%= t('tree_metric').pluralize %></h2> | ||
| 16 | 16 | ||
| 17 | <table class="table table-hover"> | 17 | <table class="table table-hover"> |
| 18 | <thead> | 18 | <thead> |
| @@ -24,10 +24,10 @@ | @@ -24,10 +24,10 @@ | ||
| 24 | </tr> | 24 | </tr> |
| 25 | </thead> | 25 | </thead> |
| 26 | <tbody> | 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 | <%= render partial: 'no_metric_configurations' %> | 28 | <%= render partial: 'no_metric_configurations' %> |
| 29 | <% else %> | 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 | <% end %> | 31 | <% end %> |
| 32 | </tbody> | 32 | </tbody> |
| 33 | </table> | 33 | </table> |
| @@ -35,6 +35,27 @@ | @@ -35,6 +35,27 @@ | ||
| 35 | 35 | ||
| 36 | <hr> | 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 | <p> | 59 | <p> |
| 39 | <%= link_to t('back'), kalibro_configurations_path, class: 'btn btn-default' %> | 60 | <%= link_to t('back'), kalibro_configurations_path, class: 'btn btn-default' %> |
| 40 | <% if kalibro_configuration_owner? @kalibro_configuration.id %> | 61 | <% if kalibro_configuration_owner? @kalibro_configuration.id %> |
config/locales/views/en.yml
| @@ -47,6 +47,10 @@ en: | @@ -47,6 +47,10 @@ en: | ||
| 47 | no_description: "There is no description available" | 47 | no_description: "There is no description available" |
| 48 | welcome: "Welcome" | 48 | welcome: "Welcome" |
| 49 | metrics: "Metrics" | 49 | metrics: "Metrics" |
| 50 | + tree_metrics: "Tree Metrics" | ||
| 51 | + tree_metric: "Tree Metric" | ||
| 52 | + hotspot_metrics: "Hotspot Metrics" | ||
| 53 | + hotspot_metric: "Hotspot Metric" | ||
| 50 | value: "Value" | 54 | value: "Value" |
| 51 | threshold: "Threshold" | 55 | threshold: "Threshold" |
| 52 | granularity: "Granularity" | 56 | granularity: "Granularity" |
config/locales/views/pt.yml
| @@ -50,6 +50,10 @@ pt: | @@ -50,6 +50,10 @@ pt: | ||
| 50 | no_description: "Não há descrição disponível." | 50 | no_description: "Não há descrição disponível." |
| 51 | welcome: "Bem-Vindo" | 51 | welcome: "Bem-Vindo" |
| 52 | metrics: "Métricas" | 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 | value: "Valor" | 57 | value: "Valor" |
| 54 | threshold: "limite" | 58 | threshold: "limite" |
| 55 | granularity: "Granularidade" | 59 | granularity: "Granularidade" |