lib/pghero/methods/query_stats.rb in pghero-3.4.1 vs lib/pghero/methods/query_stats.rb in pghero-3.6.0
- old
+ new
@@ -166,11 +166,11 @@
before ||= 14.days.ago
PgHero::QueryStats.where(database: id).where("captured_at < ?", before).delete_all
end
def slow_queries(query_stats: nil, **options)
- query_stats ||= self.query_stats(options)
+ query_stats ||= self.query_stats(**options)
query_stats.select { |q| q[:calls].to_i >= slow_query_calls.to_i && q[:average_time].to_f >= slow_query_ms.to_f }
end
def query_hash_stats(query_hash, user: nil, current: false)
if historical_query_stats_enabled? && supports_query_hash?
@@ -320,10 +320,10 @@
total_minutes: stats2.sum { |s| s[:total_minutes] },
calls: stats2.sum { |s| s[:calls] }.to_i,
all_queries_total_minutes: stats2.sum { |s| s[:all_queries_total_minutes] }
}
value[:total_percent] = value[:total_minutes] * 100.0 / value[:all_queries_total_minutes]
- value[:explainable_query] = stats2.map { |s| s[:explainable_query] }.select { |q| q && explainable?(q) }.first
+ value[:explainable_query] = stats2.map { |s| s[:explainable_query] }.find { |q| q && explainable?(q) }
query_stats << value
end
query_stats
end