charkost / prosopite

:mag: Rails N+1 queries auto-detection with zero false positives / false negatives
Apache License 2.0
1.48k stars 45 forks source link

Block syntax for scanning, finishing, pausing and resuming. #45

Open geshwho opened 2 years ago

geshwho commented 2 years ago

What do you think about supporting a block style syntax for enabling/disabling N+1 detection.

For example:

Prosopite.scan do
  example.run
end

in addition to:

Prosopite.scan
example.run
Prosopite.finish

Similarly, pausing could be something like:

Prosopite.pause do
  code_with_n+1()
end

in addition to:

Prosopite.pause
  code_with_n+1()
Prosopite.resume
oskarpearson commented 2 years ago

@geshwho I think this is now already done - let us know if you have any issues.

Block format for .scan was already implemented in the codebase - and https://github.com/charkost/prosopite/pull/41 makes the result available to the caller and puts something in the docs for this. I'm hoping it'll be merged soon

I implemented pause a while back similarly in https://github.com/charkost/prosopite/pull/42/files and it's recently been merged.

Note that currently you can't nest scan/pause/scan/pause blocks - see https://github.com/charkost/prosopite/issues/43

geshwho commented 2 years ago

@oskarpearson Oh nice! This is great, and also looks like my next two questions are also being considered:

Let me know if I can do anything to help. Looking forward to both of these!

geshwho commented 2 years ago

@oskarpearson @charkost I saw that these changes have all landed on main. Any chance you're able to cut a new release of this gem soon? I'm anxious to get my hands on block syntax 😅