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,7 +124,7 @@ class BaseMetricConfigurationsController < ApplicationController | ||
124 | metric = collector.find_metric_by_name(params[:metric_name]) | 124 | metric = collector.find_metric_by_name(params[:metric_name]) |
125 | end | 125 | end |
126 | 126 | ||
127 | - if !metric.nil? && metric.type == self.class::METRIC_TYPE | 127 | + if !metric.nil? && metric.type == metric_type |
128 | @metric_configuration.metric = metric | 128 | @metric_configuration.metric = metric |
129 | return | 129 | return |
130 | end | 130 | end |
@@ -144,4 +144,11 @@ class BaseMetricConfigurationsController < ApplicationController | @@ -144,4 +144,11 @@ class BaseMetricConfigurationsController < ApplicationController | ||
144 | end | 144 | end |
145 | end | 145 | end |
146 | end | 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 | end | 154 | end |
app/controllers/compound_metric_configurations_controller.rb
1 | class CompoundMetricConfigurationsController < BaseMetricConfigurationsController | 1 | class CompoundMetricConfigurationsController < BaseMetricConfigurationsController |
2 | - METRIC_TYPE = 'CompoundMetricSnapshot' | ||
3 | - | ||
4 | before_action :set_metric_configurations, only: [:new, :edit] | 2 | before_action :set_metric_configurations, only: [:new, :edit] |
5 | 3 | ||
6 | protected | 4 | protected |
7 | 5 | ||
8 | def set_metric! | 6 | def set_metric! |
9 | - @metric_configuration.metric.type = 'CompoundMetricSnapshot' | 7 | + @metric_configuration.metric.type = metric_type |
10 | end | 8 | end |
11 | 9 | ||
12 | def metric_configuration_params | 10 | def metric_configuration_params |
@@ -16,4 +14,8 @@ class CompoundMetricConfigurationsController < BaseMetricConfigurationsControlle | @@ -16,4 +14,8 @@ class CompoundMetricConfigurationsController < BaseMetricConfigurationsControlle | ||
16 | def set_metric_configurations | 14 | def set_metric_configurations |
17 | @metric_configurations = MetricConfiguration.metric_configurations_of(@kalibro_configuration.id) | 15 | @metric_configurations = MetricConfiguration.metric_configurations_of(@kalibro_configuration.id) |
18 | end | 16 | end |
17 | + | ||
18 | + def metric_type | ||
19 | + 'CompoundMetricSnapshot' | ||
20 | + end | ||
19 | end | 21 | end |
app/controllers/hotspot_metric_configurations_controller.rb
1 | class HotspotMetricConfigurationsController < BaseMetricConfigurationsController | 1 | class HotspotMetricConfigurationsController < BaseMetricConfigurationsController |
2 | - METRIC_TYPE = 'HotspotMetricSnapshot' | ||
3 | - | ||
4 | skip_before_action :set_reading_group! | 2 | skip_before_action :set_reading_group! |
5 | 3 | ||
6 | def metric_configuration_params | 4 | def metric_configuration_params |
@@ -12,4 +10,10 @@ class HotspotMetricConfigurationsController < BaseMetricConfigurationsController | @@ -12,4 +10,10 @@ class HotspotMetricConfigurationsController < BaseMetricConfigurationsController | ||
12 | def render_failure_html(format) | 10 | def render_failure_html(format) |
13 | format.html { redirect_to kalibro_configuration_path(@kalibro_configuration.id) } | 11 | format.html { redirect_to kalibro_configuration_path(@kalibro_configuration.id) } |
14 | end | 12 | end |
13 | + | ||
14 | + protected | ||
15 | + | ||
16 | + def metric_type | ||
17 | + 'HotspotMetricSnapshot' | ||
18 | + end | ||
15 | end | 19 | end |
app/controllers/metric_configurations_controller.rb
1 | class MetricConfigurationsController < BaseMetricConfigurationsController | 1 | class MetricConfigurationsController < BaseMetricConfigurationsController |
2 | - METRIC_TYPE = 'NativeMetricSnapshot' | ||
3 | - | ||
4 | before_action :set_reading_groups!, only: [:new, :edit] | 2 | before_action :set_reading_groups!, only: [:new, :edit] |
5 | 3 | ||
6 | def new | 4 | def new |
@@ -19,6 +17,10 @@ class MetricConfigurationsController < BaseMetricConfigurationsController | @@ -19,6 +17,10 @@ class MetricConfigurationsController < BaseMetricConfigurationsController | ||
19 | params.require(:metric_configuration).permit(:reading_group_id, :weight, :aggregation_form) | 17 | params.require(:metric_configuration).permit(:reading_group_id, :weight, :aggregation_form) |
20 | end | 18 | end |
21 | 19 | ||
20 | + def metric_type | ||
21 | + 'NativeMetricSnapshot' | ||
22 | + end | ||
23 | + | ||
22 | private | 24 | private |
23 | 25 | ||
24 | def set_reading_groups! | 26 | def set_reading_groups! |