rorvswild 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3a2d2980f4fa6ce04e070b58a75a97ab5e868a46
4
- data.tar.gz: e6b6663445113ff35fd1d2010f52e20596f9ede5
3
+ metadata.gz: c19e1237b3b9c450b21a294e2c13f7aa2d5ff2ee
4
+ data.tar.gz: 485ddeb9246497e3994ee81805b2ba3e26f084a9
5
5
  SHA512:
6
- metadata.gz: dbb08c554a475c57d39ad6538f2eaf7b9cc8b1fa61898a47447a019f89a0de57ff8f9f9e6e7f9d668ba15ff42bddf9b5bcd7ae2ba7dc5b00990308df9108b67b
7
- data.tar.gz: 952b87be7349323d78a57633974b77338ba8efc8fff7c06a94ea16508f25985bdf093f097d46bdb8c019ea373ad7c74e6d08e508a3b688dcf69031c9f413992c
6
+ metadata.gz: f36090b6aa9a61a8846cc7c6a3ade26ed05181a18b088cc88b8ae78c3cd8ec83496749bffa7a5947edd531e9eb87f1c5bb2b618360bc4bfe8897642a60a549b7
7
+ data.tar.gz: 5330075509becd02e23b9fa0599426ee8ba05d46fe8f9524cb483315662aac8d21591fa865151b3b980cb50c716893c01d5ff0fb3e3f305e5789e8c7443e3538
@@ -1,3 +1,3 @@
1
1
  class Rorvswild
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
data/lib/rorvswild.rb CHANGED
@@ -61,7 +61,7 @@ module RorVsWild
61
61
  sql, file, line, method = payload[:sql], "Unknow", 0, "Unknow" if !file
62
62
  sql = payload[:sql] if runtime >= log_sql_threshold
63
63
  plan = explain(payload[:sql], payload[:binds]) if runtime >= explain_sql_threshold
64
- queries << {file: file, line: line, method: method, sql: sql, plan: plan, runtime: runtime}
64
+ push_query(file: file, line: line, method: method, sql: sql, plan: plan, runtime: runtime, times: 1)
65
65
  rescue => exception
66
66
  log_error(exception)
67
67
  end
@@ -107,6 +107,19 @@ module RorVsWild
107
107
  @views
108
108
  end
109
109
 
110
+ def push_query(query)
111
+ if query[:sql] || query[:plan]
112
+ queries << query
113
+ else
114
+ if hash = queries.find { |hash| hash[:line] == query[:line] && hash[:file] == query[:file] }
115
+ hash[:runtime] += query[:runtime]
116
+ hash[:times] += 1
117
+ else
118
+ queries << query
119
+ end
120
+ end
121
+ end
122
+
110
123
  def slowest_views
111
124
  views.values.sort { |h1, h2| h2[:runtime] <=> h1[:runtime] }[0, 25]
112
125
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rorvswild
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexis Bernard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-06 00:00:00.000000000 Z
11
+ date: 2014-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler