Module: RailsOrbit::DashboardHelper

Defined in:
app/helpers/rails_orbit/dashboard_helper.rb

Instance Method Summary collapse

Instance Method Details

#cache_severity(hit_rate) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'app/helpers/rails_orbit/dashboard_helper.rb', line 21

def cache_severity(hit_rate)
  if hit_rate >= 80
    "success"
  elsif hit_rate >= 50
    "warning"
  else
    "danger"
  end
end

#delta_title(range_key) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/helpers/rails_orbit/dashboard_helper.rb', line 31

def delta_title(range_key)
  window = TimeRange::OPTIONS.dig(range_key, :delta_window)
  return "vs previous period" unless window
  label = case window
          when 15.minutes  then "15 min"
          when 1.hour      then "hour"
          when 6.hours     then "6 hours"
          when 1.day       then "day"
          else "period"
          end
  "vs previous #{label}"
end

#range_labelObject



7
8
9
# File 'app/helpers/rails_orbit/dashboard_helper.rb', line 7

def range_label
  @time_range.label
end

#range_optionsObject



3
4
5
# File 'app/helpers/rails_orbit/dashboard_helper.rb', line 3

def range_options
  TimeRange::OPTIONS
end

#severity_class(count, thresholds: { success: 0, warning: 10 }) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'app/helpers/rails_orbit/dashboard_helper.rb', line 11

def severity_class(count, thresholds: { success: 0, warning: 10 })
  if count <= thresholds[:success]
    "success"
  elsif count < thresholds[:warning]
    "warning"
  else
    "danger"
  end
end