Commit 0ba7d15a2e1c688ab913eff0b62ce2f180852d7e
1 parent
e6e8b204
Exists in
colab
and in
4 other branches
Create a method for retrieving metric type
Signed off by: Diego Araújo <diegoamc90@gmail.com>
Showing
4 changed files
with
23 additions
and
8 deletions
Show diff stats
app/controllers/base_metric_configurations_controller.rb
| ... | ... | @@ -124,7 +124,7 @@ class BaseMetricConfigurationsController < ApplicationController |
| 124 | 124 | metric = collector.find_metric_by_name(params[:metric_name]) |
| 125 | 125 | end |
| 126 | 126 | |
| 127 | - if !metric.nil? && metric.type == self.class::METRIC_TYPE | |
| 127 | + if !metric.nil? && metric.type == metric_type | |
| 128 | 128 | @metric_configuration.metric = metric |
| 129 | 129 | return |
| 130 | 130 | end |
| ... | ... | @@ -144,4 +144,11 @@ class BaseMetricConfigurationsController < ApplicationController |
| 144 | 144 | end |
| 145 | 145 | end |
| 146 | 146 | end |
| 147 | + | |
| 148 | + # Notice: If you add some logic to this method, remove the :nocov: below | |
| 149 | + # :nocov: | |
| 150 | + def metric_type | |
| 151 | + raise NotImplementedError | |
| 152 | + end | |
| 153 | + # :nocov: | |
| 147 | 154 | end | ... | ... |
app/controllers/compound_metric_configurations_controller.rb
| 1 | 1 | class CompoundMetricConfigurationsController < BaseMetricConfigurationsController |
| 2 | - METRIC_TYPE = 'CompoundMetricSnapshot' | |
| 3 | - | |
| 4 | 2 | before_action :set_metric_configurations, only: [:new, :edit] |
| 5 | 3 | |
| 6 | 4 | protected |
| 7 | 5 | |
| 8 | 6 | def set_metric! |
| 9 | - @metric_configuration.metric.type = 'CompoundMetricSnapshot' | |
| 7 | + @metric_configuration.metric.type = metric_type | |
| 10 | 8 | end |
| 11 | 9 | |
| 12 | 10 | def metric_configuration_params |
| ... | ... | @@ -16,4 +14,8 @@ class CompoundMetricConfigurationsController < BaseMetricConfigurationsControlle |
| 16 | 14 | def set_metric_configurations |
| 17 | 15 | @metric_configurations = MetricConfiguration.metric_configurations_of(@kalibro_configuration.id) |
| 18 | 16 | end |
| 17 | + | |
| 18 | + def metric_type | |
| 19 | + 'CompoundMetricSnapshot' | |
| 20 | + end | |
| 19 | 21 | end | ... | ... |
app/controllers/hotspot_metric_configurations_controller.rb
| 1 | 1 | class HotspotMetricConfigurationsController < BaseMetricConfigurationsController |
| 2 | - METRIC_TYPE = 'HotspotMetricSnapshot' | |
| 3 | - | |
| 4 | 2 | skip_before_action :set_reading_group! |
| 5 | 3 | |
| 6 | 4 | def metric_configuration_params |
| ... | ... | @@ -12,4 +10,10 @@ class HotspotMetricConfigurationsController < BaseMetricConfigurationsController |
| 12 | 10 | def render_failure_html(format) |
| 13 | 11 | format.html { redirect_to kalibro_configuration_path(@kalibro_configuration.id) } |
| 14 | 12 | end |
| 13 | + | |
| 14 | + protected | |
| 15 | + | |
| 16 | + def metric_type | |
| 17 | + 'HotspotMetricSnapshot' | |
| 18 | + end | |
| 15 | 19 | end | ... | ... |
app/controllers/metric_configurations_controller.rb
| 1 | 1 | class MetricConfigurationsController < BaseMetricConfigurationsController |
| 2 | - METRIC_TYPE = 'NativeMetricSnapshot' | |
| 3 | - | |
| 4 | 2 | before_action :set_reading_groups!, only: [:new, :edit] |
| 5 | 3 | |
| 6 | 4 | def new |
| ... | ... | @@ -19,6 +17,10 @@ class MetricConfigurationsController < BaseMetricConfigurationsController |
| 19 | 17 | params.require(:metric_configuration).permit(:reading_group_id, :weight, :aggregation_form) |
| 20 | 18 | end |
| 21 | 19 | |
| 20 | + def metric_type | |
| 21 | + 'NativeMetricSnapshot' | |
| 22 | + end | |
| 23 | + | |
| 22 | 24 | private |
| 23 | 25 | |
| 24 | 26 | def set_reading_groups! | ... | ... |