blob: 882211e14418c64902172cd5ae9b1b6e5971ac5d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# frozen_string_literal: true
module Gitlab
module Metrics
module Dashboard
module Stages
class Sorter < BaseStage
def transform!
missing_panel_groups! unless dashboard[:panel_groups].is_a? Array
sort_groups!
sort_panels!
end
private
# Sorts the groups in the dashboard by the :priority key
def sort_groups!
dashboard[:panel_groups] = Gitlab::Utils.stable_sort_by(dashboard[:panel_groups]) { |group| -group[:priority].to_i }
end
# Sorts the panels in the dashboard by the :weight key
def sort_panels!
dashboard[:panel_groups].each do |group|
missing_panels! unless group[:panels].is_a? Array
group[:panels] = Gitlab::Utils.stable_sort_by(group[:panels]) { |panel| -panel[:weight].to_i }
end
end
end
end
end
end
end
|