Class: Datascope
- Inherits:
-
Sinatra::Base
- Object
- Sinatra::Base
- Datascope
- Defined in:
- lib/datascope.rb
Instance Method Summary collapse
Instance Method Details
#values_by_regex(parsed, regex, ms = false) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/datascope.rb', line 65 def values_by_regex(parsed, regex, ms=false) vals = parsed.map { |row| row['stat_statements'] .select {|h| h['query'] =~ regex } .sort_by {|h| h['total_time']} .inject([0,0]) { |m,h| [m.first + h['calls'].to_i, m.last + h['total_time'].to_f ] } } if ms vals.map {|pair| pair.first.zero? ? 0 : pair.last/pair.first} else vals.map(&:first) end end |