summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/metrics_dashboard/project_metrics_inserter.rb28
-rw-r--r--lib/gitlab/metrics_dashboard/sorter.rb4
2 files changed, 16 insertions, 16 deletions
diff --git a/lib/gitlab/metrics_dashboard/project_metrics_inserter.rb b/lib/gitlab/metrics_dashboard/project_metrics_inserter.rb
index 3903bd39912..f4463645d2c 100644
--- a/lib/gitlab/metrics_dashboard/project_metrics_inserter.rb
+++ b/lib/gitlab/metrics_dashboard/project_metrics_inserter.rb
@@ -18,20 +18,6 @@ module Gitlab
private
- # Looks for a panel corresponding to the provided metric object.
- # If unavailable, inserts one.
- # @param panels [Array<Hash>]
- # @param metric [PrometheusMetric]
- def find_or_create_panel(panels, metric)
- panel = find_panel(panels, metric)
- return panel if panel
-
- panel = new_panel(metric)
- panels << panel
-
- panel
- end
-
# Looks for a panel_group corresponding to the provided metric object.
# If unavailable, inserts one.
# @param panel_groups [Array<Hash>]
@@ -46,6 +32,20 @@ module Gitlab
panel_group
end
+ # Looks for a panel corresponding to the provided metric object.
+ # If unavailable, inserts one.
+ # @param panels [Array<Hash>]
+ # @param metric [PrometheusMetric]
+ def find_or_create_panel(panels, metric)
+ panel = find_panel(panels, metric)
+ return panel if panel
+
+ panel = new_panel(metric)
+ panels << panel
+
+ panel
+ end
+
# Looks for a metric corresponding to the provided metric object.
# If unavailable, inserts one.
# @param metrics [Array<Hash>]
diff --git a/lib/gitlab/metrics_dashboard/sorter.rb b/lib/gitlab/metrics_dashboard/sorter.rb
index 9a8f87fcb6e..59b21d207e1 100644
--- a/lib/gitlab/metrics_dashboard/sorter.rb
+++ b/lib/gitlab/metrics_dashboard/sorter.rb
@@ -13,13 +13,13 @@ module Gitlab
# Sorts the groups in the dashboard by the :priority key
def sort_groups!(dashboard)
- dashboard[:panel_groups] = dashboard[:panel_groups].sort_by { |group| group[:priority] }.reverse
+ dashboard[:panel_groups] = dashboard[:panel_groups].sort_by { |group| -group[:priority].to_i }
end
# Sorts the panels in the dashboard by the :weight key
def sort_panels!(dashboard)
dashboard[:panel_groups].each do |group|
- group[:panels] = group[:panels].sort_by { |panel| panel[:weight] }.reverse
+ group[:panels] = group[:panels].sort_by { |panel| -panel[:weight].to_i }
end
end
end