Class: RailsPulse::Dashboard::NeedsAttention
- Inherits:
-
Object
- Object
- RailsPulse::Dashboard::NeedsAttention
- Defined in:
- app/models/rails_pulse/dashboard/needs_attention.rb
Constant Summary collapse
- MAX_ITEMS =
10
Constants included from Concerns::ThresholdConstants
Concerns::ThresholdConstants::CRITICAL_ERROR_RATE, Concerns::ThresholdConstants::CRITICAL_JOB_FAILURE_RATE, Concerns::ThresholdConstants::WARNING_ERROR_RATE, Concerns::ThresholdConstants::WARNING_JOB_FAILURE_RATE
Instance Method Summary collapse
-
#initialize(disabled_tags: [], show_non_tagged: true, period: 7) ⇒ NeedsAttention
constructor
A new instance of NeedsAttention.
- #to_attention_data ⇒ Object
Constructor Details
#initialize(disabled_tags: [], show_non_tagged: true, period: 7) ⇒ NeedsAttention
Returns a new instance of NeedsAttention.
7 8 9 10 11 12 13 14 |
# File 'app/models/rails_pulse/dashboard/needs_attention.rb', line 7 def initialize(disabled_tags: [], show_non_tagged: true, period: 7) @disabled_tags = @show_non_tagged = show_non_tagged @period = period @route_thresholds = RailsPulse.configuration.route_thresholds @query_thresholds = RailsPulse.configuration.query_thresholds @job_thresholds = RailsPulse.configuration.job_thresholds end |
Instance Method Details
#to_attention_data ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/models/rails_pulse/dashboard/needs_attention.rb', line 18 def to_attention_data items = route_items + query_items + job_items critical = items.select { |i| i[:severity] == :critical }.sort_by { |i| -i[:sort_score] } warning = items.select { |i| i[:severity] == :warning }.sort_by { |i| -i[:sort_score] } capped = (critical + warning).first(MAX_ITEMS) # Storage pressure items are infrastructure signals — always shown, # never subject to the 10-item app-level cap, always prepended. storage = storage_pressure_items storage_crit = storage.select { |i| i[:severity] == :critical } storage_warn = storage.select { |i| i[:severity] == :warning } { critical: storage_crit + capped.select { |i| i[:severity] == :critical }, warning: storage_warn + capped.select { |i| i[:severity] == :warning }, total: capped.size + storage.size } end |