Class: Anomonitor::MetricSample
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Anomonitor::MetricSample
- Defined in:
- app/models/anomonitor/metric_sample.rb
Class Method Summary collapse
Class Method Details
.latest_by_source_metric ⇒ Object
12 13 14 15 16 17 |
# File 'app/models/anomonitor/metric_sample.rb', line 12 def self.latest_by_source_metric recent(6).order(sampled_at: :desc).each_with_object({}) do |sample, hash| key = [sample.source, sample.metric, sample.] hash[key] ||= sample end.values end |
.series(source:, metric:, hours: 24) ⇒ Object
19 20 21 22 23 |
# File 'app/models/anomonitor/metric_sample.rb', line 19 def self.series(source:, metric:, hours: 24) where(source: source, metric: metric) .where("sampled_at >= ?", hours.hours.ago) .order(:sampled_at) end |