Class: RailsPulse::Summary

Inherits:
ApplicationRecord show all
Defined in:
app/models/rails_pulse/summary.rb

Constant Summary collapse

PERIOD_TYPES =
%w[hour day week month].freeze

Class Method Summary collapse

Class Method Details

.calculate_period_end(period_type, start_time) ⇒ Object



186
187
188
189
190
191
192
193
# File 'app/models/rails_pulse/summary.rb', line 186

def calculate_period_end(period_type, start_time)
  case period_type
  when "hour"  then start_time.end_of_hour
  when "day"   then start_time.end_of_day
  when "week"  then start_time.end_of_week
  when "month" then start_time.end_of_month
  end
end

.normalize_period_start(period_type, time) ⇒ Object



195
196
197
198
199
200
201
202
# File 'app/models/rails_pulse/summary.rb', line 195

def normalize_period_start(period_type, time)
  case period_type
  when "hour"  then time.beginning_of_hour
  when "day"   then time.beginning_of_day
  when "week"  then time.beginning_of_week
  when "month" then time.beginning_of_month
  end
end

.ransackable_associations(auth_object = nil) ⇒ Object



108
109
110
# File 'app/models/rails_pulse/summary.rb', line 108

def self.ransackable_associations(auth_object = nil)
  %w[route query job]
end

.ransackable_attributes(auth_object = nil) ⇒ Object

Ransack configuration



99
100
101
102
103
104
105
106
# File 'app/models/rails_pulse/summary.rb', line 99

def self.ransackable_attributes(auth_object = nil)
  %w[
    period_start period_end avg_duration min_duration max_duration count error_count
    requests_per_minute error_rate_percentage route_path_cont
    execution_count total_time_consumed normalized_sql
    summarizable_id summarizable_type
  ]
end