Class: SolidObserver::Services::CableStats::TrendData
- Inherits:
-
Object
- Object
- SolidObserver::Services::CableStats::TrendData
- Defined in:
- lib/solid_observer/services/cable_stats.rb
Defined Under Namespace
Classes: BucketSnapshot
Instance Method Summary collapse
-
#initialize(metric_rows:, window:, current_time:) ⇒ TrendData
constructor
A new instance of TrendData.
- #to_h ⇒ Object
Constructor Details
#initialize(metric_rows:, window:, current_time:) ⇒ TrendData
Returns a new instance of TrendData.
69 70 71 72 73 |
# File 'lib/solid_observer/services/cable_stats.rb', line 69 def initialize(metric_rows:, window:, current_time:) @metric_rows = metric_rows @window = window @current_time = current_time end |
Instance Method Details
#to_h ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/solid_observer/services/cable_stats.rb', line 75 def to_h return CableStats::ACTIVITY_TREND_EMPTY.dup if metric_rows.empty? buckets = blank_buckets metric_rows.each do |row| buckets[align_bucket(row[0].to_i)]&.add(row) end { available: true, broadcasts: count_series(buckets, :broadcasts_count), rejections: count_series(buckets, :rejections_count) } end |