smashingboxes / boxcar-generator-archive

A tool for generating Rails applications with the best practices of the Smashing Boxes team.
MIT License
16 stars 2 forks source link

Add query traces #116

Closed dkniffin closed 5 years ago

dkniffin commented 6 years ago

active-record-query-trace adds output to the logs that shows where each query was called from. This can be immensely helpful in debugging N+1 and other query related issues.

Example output:

  IntuitAccount Load (1.2ms)  SELECT "intuit_accounts".* FROM "intuit_accounts" WHERE "intuit_accounts"."user_id" = 20 LIMIT 1
Called from:
  app/views/users/edit.html.haml:78:in `block in _app_views_users_edit_html_haml___1953197429694975654_70177901460360'
  app/views/users/edit.html.haml:16:in `_app_views_users_edit_html_haml___1953197429694975654_70177901460360'
dkniffin commented 5 years ago

The gem I linked in the description doesn't seem to be maintained anymore. It's very easy to roll our own solution for this, so we should just do that. You can see an example of that on DPT: https://github.com/smashingboxes/daimler_plant_tour-api/pull/263/files#diff-f19fe47de267f47fe5edb0527c3d98a6

dkniffin commented 5 years ago

Fixed via #130