Class: Gitlab::Metrics::Dashboard::Stages::PanelIdsInserter

Inherits:
BaseStage
  • Object
show all
Defined in:
lib/gitlab/metrics/dashboard/stages/panel_ids_inserter.rb

Constant Summary

Constants included from Defaults

Defaults::DEFAULT_PANEL_TYPE

Instance Attribute Summary

Attributes inherited from BaseStage

#dashboard, #params, #project

Instance Method Summary collapse

Methods inherited from BaseStage

#initialize

Constructor Details

This class inherits a constructor from Gitlab::Metrics::Dashboard::Stages::BaseStage

Instance Method Details

#transform!Object

For each panel within given dashboard inserts panel_id unique in scope of the dashboard


9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/gitlab/metrics/dashboard/stages/panel_ids_inserter.rb', line 9

def transform!
  missing_panel_groups! unless dashboard[:panel_groups]

  for_panels_group_with_panels do |panel_group, panel|
    id = generate_panel_id(panel_group, panel)
    remove_panel_ids! && break if duplicated_panel_id?(id)

    insert_panel_id(id, panel)
  end
rescue ActiveModel::UnknownAttributeError => error
  remove_panel_ids!
  Gitlab::ErrorTracking.log_exception(error)
end