2019-07-31 22:56:46 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module Metrics
|
|
|
|
module Dashboard
|
|
|
|
# Responsible for processesing a dashboard hash, inserting
|
|
|
|
# relevant DB records & sorting for proper rendering in
|
|
|
|
# the UI. These includes shared metric info, custom metrics
|
|
|
|
# info, and alerts (only in EE).
|
|
|
|
class Processor
|
2019-12-04 20:38:33 +05:30
|
|
|
def initialize(project, dashboard, sequence, params)
|
2019-07-31 22:56:46 +05:30
|
|
|
@project = project
|
|
|
|
@dashboard = dashboard
|
2019-12-04 20:38:33 +05:30
|
|
|
@sequence = sequence
|
|
|
|
@params = params
|
2019-07-31 22:56:46 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
# Returns a new dashboard hash with the results of
|
|
|
|
# running transforms on the dashboard.
|
2019-12-26 22:10:19 +05:30
|
|
|
# @return [Hash, nil]
|
2019-12-04 20:38:33 +05:30
|
|
|
def process
|
2019-12-26 22:10:19 +05:30
|
|
|
return unless @dashboard
|
|
|
|
|
2019-07-31 22:56:46 +05:30
|
|
|
@dashboard.deep_symbolize_keys.tap do |dashboard|
|
2019-12-04 20:38:33 +05:30
|
|
|
@sequence.each do |stage|
|
|
|
|
stage.new(@project, dashboard, @params).transform!
|
2019-07-31 22:56:46 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|