fix(handlers): replace N+1 DB queries with single IN query in handle_batch_refresh_prs#278
Conversation
…batch_refresh_prs
|
👋 Thanks for opening this pull request, @ojaswa072! Before your PR is reviewed, please ensure:
🔍 Our team will review your PR shortly. If you have questions, feel free to ask in the comments. 🚀 Keep up the great work! — OWASP BLT |
📊 Monthly LeaderboardHi @ojaswa072! Here's how you rank for March 2026:
Scoring this month (across OWASP-BLT org): Open PRs (+1 each), Merged PRs (+10), Closed (not merged) (−2), Reviews (+5; first two per PR in-month), Comments (+2, excludes CodeRabbit). Run |
|
👋 Hi @ojaswa072! This pull request needs a peer review before it can be merged. Please request a review from a team member who is not:
Once a valid peer review is submitted, this check will pass automatically. Thank you!
|
🍃 PR Readiness CheckCheck the readiness of this PR on Leaf: Leaf reviews pull requests for operational readiness, security risks, and production-impacting changes before they ship. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: OWASP-BLT/coderabbit/.coderabbit.yml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughOptimizes Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Suggested labels
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Fixed an N+1 database query problem in
handle_batch_refresh_prs.Problem
The original code fetched PR details from the database in a loop — one query per PR ID:
For 100 PRs (the maximum allowed), this meant 100 sequential database round-trips before the GitHub batch API call even started.
Fix
Replaced the loop with a single
WHERE id IN (...)query that fetches all PRs in one round-trip:Not-found IDs are still logged individually for debugging.
Impact
Files Changed
src/handlers.py—handle_batch_refresh_prsfunctionSummary by CodeRabbit
Refactor
Bug Fixes