lib/pghero/methods/query_stats.rb in pghero-1.6.2 vs lib/pghero/methods/query_stats.rb in pghero-1.6.3

- old
+ new

@@ -64,10 +64,12 @@ end # http://stackoverflow.com/questions/20582500/how-to-check-if-a-table-exists-in-a-given-schema def historical_query_stats_enabled? # TODO use schema from config + # make sure primary database is PostgreSQL first + ["PostgreSQL", "PostGIS"].include?(stats_connection.adapter_name) && PgHero.truthy?(stats_connection.select_all(squish <<-SQL SELECT EXISTS ( SELECT 1 FROM @@ -144,9 +146,14 @@ insert_stats("pghero_query_stats", columns, values) end end end + end + + def slow_queries(options = {}) + query_stats = options[:query_stats] || self.query_stats(options.except(:query_stats)) + query_stats.select { |q| q["calls"].to_i >= slow_query_calls.to_i && q["average_time"].to_i >= slow_query_ms.to_i } end private def stats_connection