2019-04-24 23:03:50 -04:00
|
|
|
# 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-09-18 10:02:45 -04:00
|
|
|
def initialize(project, dashboard, sequence, params)
|
2019-04-24 23:03:50 -04:00
|
|
|
@project = project
|
2019-04-25 02:13:43 -04:00
|
|
|
@dashboard = dashboard
|
2019-09-18 10:02:45 -04:00
|
|
|
@sequence = sequence
|
|
|
|
@params = params
|
2019-04-24 23:03:50 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
# Returns a new dashboard hash with the results of
|
|
|
|
# running transforms on the dashboard.
|
2019-10-21 08:06:14 -04:00
|
|
|
# @return [Hash, nil]
|
2019-09-18 10:02:45 -04:00
|
|
|
def process
|
2019-10-21 08:06:14 -04:00
|
|
|
return unless @dashboard
|
|
|
|
|
2019-04-25 02:13:43 -04:00
|
|
|
@dashboard.deep_symbolize_keys.tap do |dashboard|
|
2019-09-18 10:02:45 -04:00
|
|
|
@sequence.each do |stage|
|
|
|
|
stage.new(@project, dashboard, @params).transform!
|
2019-04-25 02:00:51 -04:00
|
|
|
end
|
|
|
|
end
|
2019-04-24 23:03:50 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|