<commit_before>= Query Diet

Query Diet counts the number of database queries for the last request and *subtly* displays it in the upper right corner of your screen.
The display turns red if too many queries are run, or if they take too long.
This is useful to prevent {N + 1 queries}[http://guides.rubyonrails.org/active_record_querying.html#eager-loading-associations] from creeping into your code.

This is Query Diet being happy about 3 requests taking 66ms:

http://blog.makandra.com/images/articles/2010-06-25-solving-the-n-1-query-problem-with-query-diet/query_diet_happy.png

This is Query Diet being angry about 103 requests taking 164ms:

http://blog.makandra.com/images/articles/2010-06-25-solving-the-n-1-query-problem-with-query-diet/query_diet_angry.png

== Installation

Add it to your Gemfile with
    gem 'query_diet'


Now add the widget to your application layout, like

    # app/views/layout/application.html.erb
    # ...
    <body>
      <%= query_diet_widget if Rails.env.development? %>
      <%= yield %>
    </body>
   

We recommend you only use the gem with the development environment.

== Changing warning thresholds

You can define when the counter turns into a red warning. The default threshold is 8 queries and 5000 miliseconds.
To change the default, simply pass them to the `query_diet_widget` helper:

    <%= query_diet_widget(:bad_count => 4, :bad_time => 2000) %>


== Rails compatibility

The gem is tested to work with Rails 2.3, Rails 3.0 and Rails 3.2.


=== Credits

<NAME>

<NAME>

{makandra.com}[http://makandra.com/]

{gem-session.com}[http://gem-session.com/]

{<NAME>}[https://github.com/grosser]<commit_msg>update Rails compatibility in README<commit_after>= Query Diet

Query Diet counts the number of database queries for the last request and *subtly* displays it in the upper right corner of your screen.
The display turns red if too many queries are run, or if they take too long.
This is useful to prevent {N + 1 queries}[http://guides.rubyonrails.org/active_record_querying.html#eager-loading-associations] from creeping into your code.

This is Query Diet being happy about 3 requests taking 66ms:

http://blog.makandra.com/images/articles/2010-06-25-solving-the-n-1-query-problem-with-query-diet/query_diet_happy.png

This is Query Diet being angry about 103 requests taking 164ms:

http://blog.makandra.com/images/articles/2010-06-25-solving-the-n-1-query-problem-with-query-diet/query_diet_angry.png



== Installation

Add it to your Gemfile with
    gem 'query_diet'


Now add the widget to your application layout, like

    # app/views/layout/application.html.erb
    # ...
    <body>
      <%= query_diet_widget if Rails.env.development? %>
      <%= yield %>
    </body>
   

We recommend you only use the gem with the development environment.

== Changing warning thresholds

You can define when the counter turns into a red warning. The default threshold is 8 queries and 5000 miliseconds.
To change the default, simply pass them to the `query_diet_widget` helper:

    <%= query_diet_widget(:bad_count => 4, :bad_time => 2000) %>


== Rails compatibility

The gem is tested to work with Rails 3.2+ and Ruby 2.0+.

For Rails 2.3 and Ruby 1.8.7 support, use a version <= 0.5.4.


=== Credits

<NAME>

<NAME>

{makandra.com}[http://makandra.com/]

{gem-session.com}[http://gem-session.com/]

{<NAME>}[https://github.com/grosser]
{'fraction_non_alphanumeric': 0.10394581861012957, 'fraction_numerical': 0.02767962308598351, 'mean_word_length': 3.8321479374110954, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 23, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2580822', 'n_tokens_mistral': 1186, 'n_tokens_neox': 1048, 'n_words': 364}