Module: RailsErrorDashboard::OverviewHelper

Includes:
I18nHelper
Defined in:
app/helpers/rails_error_dashboard/overview_helper.rb

Instance Method Summary collapse

Methods included from I18nHelper

#red_chart_date, #red_js_t, #red_js_tp, #red_js_translations, #red_locale, #red_t, #red_time_format, #red_tp

Instance Method Details

#error_rate_border_class(rate) ⇒ Object

All helper methods return Bootstrap semantic classes (success, warning, danger) These automatically map to Catppuccin Mocha colors in dark theme via CSS variables:

  • success → --ctp-green
  • warning → --ctp-peach
  • danger → --ctp-red


15
16
17
18
19
# File 'app/helpers/rails_error_dashboard/overview_helper.rb', line 15

def error_rate_border_class(rate)
  return "border-success" if rate < 1.0
  return "border-warning" if rate < 5.0
  "border-danger"
end

#error_rate_text_class(rate) ⇒ Object



21
22
23
24
25
# File 'app/helpers/rails_error_dashboard/overview_helper.rb', line 21

def error_rate_text_class(rate)
  return "text-success" if rate < 1.0
  return "text-warning" if rate < 5.0
  "text-danger"
end

#health_status_color(status) ⇒ Object



64
65
66
67
68
69
70
71
72
73
# File 'app/helpers/rails_error_dashboard/overview_helper.rb', line 64

def health_status_color(status)
  case status
  when :healthy
    "success"
  when :warning
    "warning"
  else
    "danger"
  end
end

#health_status_text(status) ⇒ Object

The emoji is part of the English rendering and lives in the key so a locale can drop it. These are deliberately not the red.analytics.platform_comparison.health_card keys — that page renders the same states without emoji.



79
80
81
82
83
84
85
86
87
88
# File 'app/helpers/rails_error_dashboard/overview_helper.rb', line 79

def health_status_text(status)
  case status
  when :healthy
    red_t("red.common.health_status.healthy")
  when :warning
    red_t("red.common.health_status.warning")
  else
    red_t("red.common.health_status.critical")
  end
end

#severity_icon(severity) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
# File 'app/helpers/rails_error_dashboard/overview_helper.rb', line 51

def severity_icon(severity)
  case severity
  when :critical
    "🔴"
  when :high
    "🟠"
  when :medium
    "🟡"
  else
    ""
  end
end

#trend_arrow(value) ⇒ Object



27
28
29
30
# File 'app/helpers/rails_error_dashboard/overview_helper.rb', line 27

def trend_arrow(value)
  return "" if value.zero?
  value > 0 ? "" : ""
end

#trend_color_class(value) ⇒ Object



32
33
34
35
# File 'app/helpers/rails_error_dashboard/overview_helper.rb', line 32

def trend_color_class(value)
  return "text-muted" if value.zero?
  value > 0 ? "text-danger" : "text-success"
end

#trend_text(direction) ⇒ Object

The direction is a machine symbol; these are its display labels. An unrecognized value reads as stable, which is what the English original did with its else branch.



40
41
42
43
44
45
46
47
48
49
# File 'app/helpers/rails_error_dashboard/overview_helper.rb', line 40

def trend_text(direction)
  case direction
  when :increasing
    red_t("red.common.trend.increasing")
  when :decreasing
    red_t("red.common.trend.decreasing")
  else
    red_t("red.common.trend.stable")
  end
end