Class: RailsPulse::Query
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Taggable
#add_tag, #has_tag?, #remove_tag, #tag_list, #tag_list=
Class Method Details
.ransackable_associations(auth_object = nil) ⇒ Object
25
26
27
|
# File 'app/models/rails_pulse/query.rb', line 25
def self.ransackable_associations(auth_object = nil)
%w[operations]
end
|
.ransackable_attributes(auth_object = nil) ⇒ Object
21
22
23
|
# File 'app/models/rails_pulse/query.rb', line 21
def self.ransackable_attributes(auth_object = nil)
%w[id normalized_sql average_query_time_ms execution_count total_time_consumed performance_status occurred_at]
end
|
Instance Method Details
#analysis_status ⇒ Object
83
84
85
86
87
|
# File 'app/models/rails_pulse/query.rb', line 83
def analysis_status
return "not_analyzed" unless analyzed?
return "needs_update" if needs_reanalysis?
"current"
end
|
#analyzed? ⇒ Boolean
65
66
67
|
# File 'app/models/rails_pulse/query.rb', line 65
def analyzed?
analyzed_at.present?
end
|
#critical_issues_count ⇒ Object
95
96
97
|
# File 'app/models/rails_pulse/query.rb', line 95
def critical_issues_count
issues_by_severity["critical"]&.count || 0
end
|
#has_recent_operations? ⇒ Boolean
69
70
71
|
# File 'app/models/rails_pulse/query.rb', line 69
def has_recent_operations?
operations.where("occurred_at > ?", 48.hours.ago).exists?
end
|
#issues_by_severity ⇒ Object
89
90
91
92
93
|
# File 'app/models/rails_pulse/query.rb', line 89
def issues_by_severity
return {} unless analyzed? && issues.present?
issues.group_by { |issue| issue["severity"] || "unknown" }
end
|
#needs_reanalysis? ⇒ Boolean
73
74
75
76
77
78
79
80
81
|
# File 'app/models/rails_pulse/query.rb', line 73
def needs_reanalysis?
return true unless analyzed?
last_operation_time = operations.maximum(:occurred_at)
return false unless last_operation_time
last_operation_time > analyzed_at
end
|
#to_s ⇒ Object
103
104
105
|
# File 'app/models/rails_pulse/query.rb', line 103
def to_s
id
end
|
#warning_issues_count ⇒ Object
99
100
101
|
# File 'app/models/rails_pulse/query.rb', line 99
def warning_issues_count
issues_by_severity["warning"]&.count || 0
end
|