Permalink
Browse files

Deprecated my version of query_reviewer and passed it off to nesquena

  • Loading branch information...
1 parent 8202e49 commit 0457766d9fda71f7b55611fa27e8ffc63ade1793 @dsboulder committed Aug 28, 2011
Showing with 4 additions and 1,648 deletions.
  1. +0 −20 MIT-LICENSE
  2. +4 −118 README.md
  3. +0 −24 Rakefile
  4. +0 −1 init.rb
  5. +0 −50 lib/query_reviewer.rb
  6. +0 −29 lib/query_reviewer/array_extensions.rb
  7. +0 −65 lib/query_reviewer/controller_extensions.rb
  8. +0 −90 lib/query_reviewer/mysql_adapter_extensions.rb
  9. +0 −62 lib/query_reviewer/mysql_analyzer.rb
  10. +0 −17 lib/query_reviewer/query_warning.rb
  11. +0 −37 lib/query_reviewer/rails.rb
  12. +0 −130 lib/query_reviewer/sql_query.rb
  13. +0 −103 lib/query_reviewer/sql_query_collection.rb
  14. +0 −45 lib/query_reviewer/sql_sub_query.rb
  15. +0 −8 lib/query_reviewer/tasks.rb
  16. +0 −11 lib/query_reviewer/views/_box.html.erb
  17. +0 −34 lib/query_reviewer/views/_box_ajax.js
  18. +0 −73 lib/query_reviewer/views/_box_body.html.erb
  19. +0 −2 lib/query_reviewer/views/_box_disabled.html.erb
  20. +0 −1 lib/query_reviewer/views/_box_header.html.erb
  21. +0 −234 lib/query_reviewer/views/_box_includes.html.erb
  22. +0 −30 lib/query_reviewer/views/_explain.html.erb
  23. +0 −68 lib/query_reviewer/views/_js_includes.html.erb
  24. +0 −68 lib/query_reviewer/views/_js_includes_new.html.erb
  25. +0 −26 lib/query_reviewer/views/_profile.html.erb
  26. +0 −8 lib/query_reviewer/views/_query_sql.html.erb
  27. +0 −31 lib/query_reviewer/views/_query_trace.html.erb
  28. +0 −54 lib/query_reviewer/views/_query_with_warning.html.erb
  29. +0 −10 lib/query_reviewer/views/_spectrum.html.erb
  30. +0 −8 lib/query_reviewer/views/_warning_no_query.html.erb
  31. +0 −98 lib/query_reviewer/views/query_review_box_helper.rb
  32. +0 −10 query_reviewer.gemspec
  33. +0 −39 query_reviewer_defaults.yml
  34. +0 −1 rails/init.rb
  35. +0 −8 test/sql_query_test.rb
  36. +0 −17 test/sql_sub_query_test.rb
  37. +0 −18 test/test_helper.rb
View
@@ -1,20 +0,0 @@
-Copyright (c) 2007 [name of plugin creator]
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
122 README.md
@@ -1,122 +1,8 @@
# QueryReviewer #
-## Introduction ##
+I am not longer maintaining `query_reviewier`. Nathan has done a much better job keeping my plugin and idea up to date, please use his fork at the following location:
-QueryReviewer is an advanced SQL query analyzer. It accomplishes the following goals:
+[https://github.com/nesquena/query_reviewer](https://github.com/nesquena/query_reviewer)
- * View all EXPLAIN output for all SELECT queries to generate a page
- * Rate a page's SQL usage into one of three categories: OK, WARNING, CRITICAL
- * Attach meaningful warnings to individual queries, and collections of queries
- * Display interactive summary on page
-
-## This Fork ##
-
-I use this utility for most of my rails projects. Still the best out there in my opinion for analyzing and understanding your generated SQL queries. I forked the original [query_reviewer](https://github.com/dsboulder/query_reviewer) and applied a collection of patches that have been made since the plugin was created. A list of the biggest additions below:
-
- * Snazzed up the README into markdown for better readability
- * Full compatibility for Rails 3 (including Railtie)
- * Cleanup and move rake task to `lib/tasks` to fix deprecation warnings
- * Added gemspec for use with Bundler (as a gem)
- * Fixed missing tags and additional XHTML escaping
- * Fix SQL escaping for better XHTML compatibility
- * Fixes for deprecation warnings and for 1.9 compatiblity
- * Converts templates to more modern foo.html.erb naming
-
-Last commit to the main repository was on March 30th, 2009. This fork compiles a variety of patches that were made since that time along with additional work to support compatibility with 1.9 and Rails 3. **Also:** If anyone else creates generally useful enhancements to this utility please start by forking this and then issue me a pull request.
-
-**Note:** This plugin should work for Rails 2.X and Rails 3. Support for Rails 3 has been confirmed in the latest revision (with fixed deprecation warnings).
-
-## Installation ##
-
-All you have to do is install it into your Rails 2 or 3 project.
-
- gem install query_reviewer
-
-Right now if you use bundler, simply add this to your Gemfile:
-
- # Gemfile
- gem "query_reviewer", :git => "git://github.com/nesquena/query_reviewer.git"
-
-If you are not using bundler, you might want to [start using it](http://gembundler.com/rails23.html). You can also install this as a plugin:
-
- script/plugin install git://github.com/nesquena/query_reviewer.git
-
-In Rails 2, the rake tasks are not loaded automatically (as a gem), you’ll need to add the following to your Rakefile:
-
- # Rakefile
- begin
- require 'query_reviewer/tasks'
- rescue LoadError
- STDERR.puts "The query_reviewer gem could not be found!"
- end
-
-You can then run:
-
- $ rake query_reviewer:setup
-
-Which will create `config/query_reviewer.yml` in your application, see below for what these options mean.
-If you don't create a config file, the gem will use the default in `vendor/plugins/query_reviewer`.
-
-## Configuration ##
-
-The configuration file allows you to set configuration parameters shared across all rails environment, as well as overriding those shared parameteres with environment-specific parameters (such as disabling analysis on production!)
-
- * `enabled`: whether any output or query analysis is performed. Set this false in production!
- * `inject_view`: controls whether the output automatically is injected before the </body> in HTML output.
- * `profiling`: when enabled, runs the MySQL SET PROFILING=1 for queries longer than the `warn_duration_threshold` / 2.0
- * `production_data`: whether the duration of a query should be taken into account
- * `stack_trace_lines`: number of lines of call stack to include in the "short" version of the stack trace
- * `trace_includes_vendor`: whether the "short" verison of the stack trace should include files in /vendor
- * `trace_includes_lib`: whether the "short" verison of the stack trace should include files in /lib
- * `warn_severity`: the severity of problem that merits "WARNING" status
- * `critical_severity`: the severity of problem that merits "CRITICAL" status
- * `warn_query_count`: the number of queries in a single request that merits "WARNING" status
- * `critical_query_count`: the number of queries in a single request that merits "CRITICAL" status
- * `warn_duration_threshold`: how long a query must take in seconds (float) before it's considered "WARNING"
- * `critical_duration_threshold`: how long a query must take in seconds (float) before it's considered "CRITICIAL"
-
-## Example ##
-
-If you disable the inject_view option above, you'll need to manually put the analyzer's output into your view:
-
- # view.html.haml
- = query_review_output
-
-and that will display the analyzer view!
-
-## Resources ##
-
-Random collection of resources that might be interesting related to this utility:
-
- * <http://blog.purifyapp.com/2010/06/15/optimise-your-mysql/>
- * <http://www.tatvartha.com/2009/09/rails-optimizing-database-indexes-using-query_analyzer-and-query_reviewer/>
- * <http://www.geekskillz.com/articles/using-indexes-to-improve-rails-performance>
- * <http://www.williambharding.com/blog/rails/rails-mysql-indexes-step-1-in-pitiful-to-prime-performance/>
- * <http://guides.rubyonrails.org/performance_testing.html>
-
-Other related gems that prove useful for database optimization:
-
- * [bullet](https://github.com/flyerhzm/bullet)
- * [slim-scrooge](https://github.com/sdsykes/slim_scrooge)
- * [slim-attributes](https://github.com/sdsykes/slim-attributes)
-
-## Alternatives ##
-
-There have been other alternatives created since this was originally released. A few of the best are listed below. I for one still prefer this utility over the other options:
-
- * [rack-bug](https://github.com/brynary/rack-bug)
- * [rails-footnotes](https://github.com/josevalim/rails-footnotes)
- * [newrelic-development](http://support.newrelic.com/kb/docs/developer-mode)
- * [palmist](https://github.com/flyingmachine/palmist)
- * [query_diet](https://github.com/makandra/query_diet)
- * [query_trace](https://github.com/ntalbott/query_trace)
-
-Know of a better alternative? Let me know!
-
-## Acknowledgements ##
-
-Created by Kongregate & David Stevenson.
-Refactorings and compilations of all fixes since was done by Nathan Esquenazi.
-Also, ajvargo for helping with some fixes.
-
-Copyright (c) 2007-2008 Kongregate & David Stevenson, released under the MIT license
+-David Stevenson
+[http://flouri.sh](http://flouri.sh)
View
@@ -1,24 +0,0 @@
-require 'rake'
-require 'rake/testtask'
-require 'rake/rdoctask'
-require 'bundler'
-Bundler::GemHelper.install_tasks
-
-desc 'Default: run unit tests.'
-task :default => :test
-
-desc 'Test the query_reviewer plugin.'
-Rake::TestTask.new(:test) do |t|
- t.libs << 'lib'
- t.pattern = 'test/**/*_test.rb'
- t.verbose = true
-end
-
-desc 'Generate documentation for the query_reviewer plugin.'
-Rake::RDocTask.new(:rdoc) do |rdoc|
- rdoc.rdoc_dir = 'rdoc'
- rdoc.title = 'QueryReviewer'
- rdoc.options << '--line-numbers' << '--inline-source'
- rdoc.rdoc_files.include('README')
- rdoc.rdoc_files.include('lib/**/*.rb')
-end
View
@@ -1 +0,0 @@
-require File.dirname(__FILE__) + "/rails/init"
View
@@ -1,50 +0,0 @@
-# QueryReviewer
-require "ostruct"
-require 'erb'
-require 'yaml'
-
-module QueryReviewer
- CONFIGURATION = {}
-
- def self.load_configuration
- default_config = YAML::load(ERB.new(IO.read(File.join(File.dirname(__FILE__), "..", "query_reviewer_defaults.yml"))).result)
-
- CONFIGURATION.merge!(default_config["all"] || {})
- CONFIGURATION.merge!(default_config[Rails.env || "test"] || {})
-
- app_config_file = Rails.root + "config/query_reviewer.yml"
-
- if app_config_file.exist?
- app_config = YAML.load(ERB.new(IO.read(app_config_file)).result)
- CONFIGURATION.merge!(app_config["all"] || {})
- CONFIGURATION.merge!(app_config[Rails.env || "test"] || {})
- end
-
- if enabled?
- begin
- CONFIGURATION["uv"] ||= !Gem.searcher.find("uv").nil?
- if CONFIGURATION["uv"]
- require "uv"
- end
- rescue
- CONFIGURATION["uv"] ||= false
- end
-
- require "query_reviewer/query_warning"
- require "query_reviewer/array_extensions"
- require "query_reviewer/sql_query"
- require "query_reviewer/mysql_analyzer"
- require "query_reviewer/sql_sub_query"
- require "query_reviewer/mysql_adapter_extensions"
- require "query_reviewer/controller_extensions"
- require "query_reviewer/sql_query_collection"
- end
- end
-
- def self.enabled?
- CONFIGURATION["enabled"]
- end
-end
-
-# Rails Integration
-require 'query_reviewer/rails' if defined?(Rails)
@@ -1,29 +0,0 @@
-module QueryReviewer
- module ArrayExtensions #taken from query_analyser plugin
- protected
- def qa_columnized_row(fields, sized)
- row = []
- fields.each_with_index do |f, i|
- row << sprintf("%0-#{sized[i]}s", f.to_s)
- end
- row.join(' | ')
- end
-
- public
-
- def qa_columnized
- sized = {}
- self.each do |row|
- row.values.each_with_index do |value, i|
- sized[i] = [sized[i].to_i, row.keys[i].length, value.to_s.length].max
- end
- end
-
- table = []
- table << qa_columnized_row(self.first.keys, sized)
- table << '-' * table.first.length
- self.each { |row| table << qa_columnized_row(row.values, sized) }
- table.join("\n ") # Spaces added to work with format_log_entry
- end
- end
-end
@@ -1,65 +0,0 @@
-require "action_view"
-require File.join(File.dirname(__FILE__), "views", "query_review_box_helper")
-
-module QueryReviewer
- module ControllerExtensions
- class QueryViewBase < ActionView::Base
- include QueryReviewer::Views::QueryReviewBoxHelper
- end
-
- def self.included(base)
- if QueryReviewer::CONFIGURATION["inject_view"]
- alias_name = defined?(Rails::Railtie) ? :process_action : :perform_action
- base.alias_method_chain(alias_name, :query_review)
- end
- base.alias_method_chain :process, :query_review
- base.helper_method :query_review_output
- end
-
- def query_review_output(ajax = false, total_time = nil)
- faux_view = QueryViewBase.new([File.join(File.dirname(__FILE__), "views")], {}, self)
- queries = Thread.current["queries"]
- queries.analyze!
- faux_view.instance_variable_set("@queries", queries)
- faux_view.instance_variable_set("@total_time", total_time)
- if ajax
- js = faux_view.render(:partial => "/box_ajax.js")
- else
- html = faux_view.render(:partial => "/box")
- end
- end
-
- def add_query_output_to_view(total_time)
- if request.xhr?
- if cookies["query_review_enabled"]
- if !response.content_type || response.content_type.include?("text/html")
- response.body += "<script type=\"text/javascript\">"+query_review_output(true, total_time)+"</script>"
- elsif response.content_type && response.content_type.include?("text/javascript")
- response.body += ";\n"+query_review_output(true, total_time)
- end
- end
- else
- if response.body.is_a?(String) && response.body.match(/<\/body>/i) && Thread.current["queries"]
- idx = (response.body =~ /<\/body>/i)
- html = query_review_output(false, total_time)
- response.body = response.body.insert(idx, html)
- end
- end
- end
-
- def perform_action_with_query_review(*args)
- Thread.current["query_reviewer_enabled"] = cookies["query_review_enabled"]
- t1 = Time.now
- r = defined?(Rails::Railtie) ? process_action_without_query_review(*args) : perform_action_without_query_review(*args)
- t2 = Time.now
- add_query_output_to_view(t2 - t1)
- r
- end
- alias_method :process_action_with_query_review, :perform_action_with_query_review
-
- def process_with_query_review(*args) #:nodoc:
- Thread.current["queries"] = SqlQueryCollection.new
- process_without_query_review(*args)
- end
- end
-end
Oops, something went wrong.

0 comments on commit 0457766

Please sign in to comment.