Skip to content

Commit

Permalink
fixed bug which set label to :select after :columns
Browse files Browse the repository at this point in the history
git-svn-id: https://query-stats.googlecode.com/svn/trunk/query_stats@6 71187760-d61d-0410-86ff-8714271a0d44
  • Loading branch information
daniel.manges committed Sep 22, 2006
1 parent bede4e0 commit 6f5bc6e
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 4 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG
@@ -1,4 +1,5 @@
= Query Stats Change Log

* September 22, 2006
* Fixed bug causing project test methods to fail when using assigns(:variable)
* Fixed bug causing project test methods to fail when using assigns(:variable)
* Fixed bug which set label to :select after :columns, QueryStatsHolder#with_label will successfully ignore column queries.
6 changes: 4 additions & 2 deletions README
Expand Up @@ -28,7 +28,9 @@ If you include QueryStats in your controller, you can easily display statistics
queries.count_with_label :controller
queries.count_with_label :view
queries.total_time

(If you do not wait until the end, you will not capture all the view queries)

Note: The count_with_label method automatically excludes queries Rails executes to read table columns
since those query results are cached in production. To include those queries, call count_with_label(:label, false).
Also, make sure you wait until the end of your view, or you will not capture all the view queries.

Copyright (c) 2006 Daniel Manges, released under the MIT license.
1 change: 1 addition & 0 deletions Rakefile
Expand Up @@ -18,5 +18,6 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
rdoc.title = 'QueryStats'
rdoc.options << '--line-numbers' << '--inline-source'
rdoc.rdoc_files.include('README')
rdoc.rdoc_files.include('CHANGELOG')
rdoc.rdoc_files.include('lib/**/*.rb')
end
3 changes: 2 additions & 1 deletion lib/active_record/connection_adapters/query_stats.rb
Expand Up @@ -19,7 +19,7 @@ def self.append_features(base)
base.class_eval do
QUERY_METHODS.each do |method|
define_method("#{method}_with_query_stats") do |*args|
queries.query_type = method
queries.query_type = method unless queries.query_type == :columns
send "#{method}_without_query_stats", *args
end
alias_method "#{method}_without_query_stats", method
Expand All @@ -41,6 +41,7 @@ def execute_with_query_stats(*args)
result = execute_without_query_stats(*args)
end
queries.add(seconds, *args)
queries.query_type = nil
result
end
end
Expand Down
2 changes: 2 additions & 0 deletions lib/query_stats_holder.rb
Expand Up @@ -17,6 +17,8 @@ class QueryStatsHolder
# Gets or sets the current label to be applied to queries for custom tracking.
# Including QueryStats in ApplicationController will label queries :controller or :view
attr_accessor :label
# Gets the current query type
attr_reader :query_type

# Creates a new instance of QueryStatsHolder with an empty array of stats.
def initialize
Expand Down

0 comments on commit 6f5bc6e

Please sign in to comment.