Commit 7be7c444 authored by syasonik's avatar syasonik

Port Processer api refactor from CE

parent 5d3e42fa
...@@ -4,8 +4,8 @@ module EE ...@@ -4,8 +4,8 @@ module EE
module Gitlab module Gitlab
module MetricsDashboard module MetricsDashboard
module Processor module Processor
def stages def sequence
@stages ||= super + [Stages::AlertsInserter] super + [Stages::AlertsInserter]
end end
end end
end end
......
...@@ -7,10 +7,10 @@ module EE ...@@ -7,10 +7,10 @@ module EE
module MetricsDashboard module MetricsDashboard
module Stages module Stages
class AlertsInserter < ::Gitlab::MetricsDashboard::Stages::BaseStage class AlertsInserter < ::Gitlab::MetricsDashboard::Stages::BaseStage
def transform! def transform!(dashboard)
return if metrics_with_alerts.empty? return if metrics_with_alerts.empty?
for_metrics do |metric| for_metrics(dashboard) do |metric|
next unless metrics_with_alerts.include?(metric[:metric_id]) next unless metrics_with_alerts.include?(metric[:metric_id])
metric[:alert_path] = alert_path(metric[:metric_id], project, environment) metric[:alert_path] = alert_path(metric[:metric_id], project, environment)
......
...@@ -7,19 +7,19 @@ describe Gitlab::MetricsDashboard::Processor do ...@@ -7,19 +7,19 @@ describe Gitlab::MetricsDashboard::Processor do
let(:environment) { create(:environment, project: project) } let(:environment) { create(:environment, project: project) }
let(:dashboard_yml) { YAML.load_file('spec/fixtures/lib/gitlab/metrics_dashboard/sample_dashboard.yml') } let(:dashboard_yml) { YAML.load_file('spec/fixtures/lib/gitlab/metrics_dashboard/sample_dashboard.yml') }
describe 'stages' do describe 'sequence' do
let(:environment) { build(:environment) } let(:environment) { build(:environment) }
let(:process_params) { [dashboard_yml, project, environment] } let(:process_params) { [project, environment] }
let(:stages) { described_class.new(*process_params).stages } let(:sequence) { described_class.new(*process_params).sequence }
it 'includes the alerts processing stage' do it 'includes the alerts processing stage' do
expect(stages.length).to eq(4) expect(sequence.length).to eq(4)
end end
end end
describe 'process' do describe 'process' do
let(:process_params) { [dashboard_yml, project, environment] } let(:process_params) { [project, environment] }
let(:dashboard) { described_class.new(*process_params).process } let(:dashboard) { described_class.new(*process_params).process(dashboard_yml) }
context 'when the dashboard references persisted metrics with alerts' do context 'when the dashboard references persisted metrics with alerts' do
let!(:alert) do let!(:alert) do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment