lib/dexter/collector.rb in pgdexter-0.2.1 vs lib/dexter/collector.rb in pgdexter-0.3.0
- old
+ new
@@ -3,10 +3,11 @@
def initialize(options = {})
@top_queries = {}
@new_queries = Set.new
@mutex = Mutex.new
@min_time = options[:min_time] * 60000 # convert minutes to ms
+ @min_calls = options[:min_calls]
end
def add(query, duration)
fingerprint =
begin
@@ -34,10 +35,10 @@
@new_queries.clear
end
queries = []
@top_queries.each do |k, v|
- if new_queries.include?(k) && v[:total_time] > @min_time
+ if new_queries.include?(k) && v[:total_time] >= @min_time && v[:calls] >= @min_calls
query = Query.new(v[:query], k)
query.total_time = v[:total_time]
query.calls = v[:calls]
queries << query
end