Tijani-Dia / dj-tracker

A Django app that tracks your queries to help optimize them. Demo: https://dj-tracker-bakerydemo.fly.dev/dj-tracker/
https://tijani-dia.github.io/dj-tracker/
BSD 3-Clause "New" or "Revised" License
79 stars 3 forks source link

Add Dj-tracker directly to Test DB and see the dashboard. #30

Open rjsnh1522 opened 6 months ago

rjsnh1522 commented 6 months ago

Found this tool very useful. However, it's difficult to go to each URL and record it in Dj-tracker. Is there any way to include it in test cases? I have around 1600 test cases covering all scenarios of my project. I want to generate a report after running all the test cases, which would display all the records and data in one place. N+1 queries are very notorious, and checking them one by one is difficult.

Do you think it's possible to achieve this?

Tijani-Dia commented 1 month ago

Hey @rjsnh1522, thanks for trying it out.

Is there any way to include it in test cases?

Yes, adding TEST_RUNNER = "dj_tracker.test.DjTrackerRunner" in your test settings will ensure the tracker is started before the test suite is run.

I'd highly recommend adding the trackings database - otherwise the tracking data may be lost since test databases aren't generally preserved between runs.

I want to generate a report after running all the test cases, which would display all the records and data in one place. N+1 queries are very notorious, and checking them one by one is difficult.

Can you please elaborate on this? Do you have an idea of how the report would look like for example? I totally agree that checking optimisation spots one by one isn't a pleasant experience and is something that definitely needs to be improved.