Repository navigation
perf: bound unbounded findMany queries (#1206) - #1214
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
📝 WalkthroughWalkthroughThis PR adds result limits to two database query paths in the bot services to prevent unbounded record retrieval. The music recommendation service caps artist preference lookups at 5000 records per query, and the birthday scheduler replaces a single unbounded guild settings query with paginated 500-record batches. ChangesDatabase Query Result Bounding
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
|
Failed to generate code suggestions for PR |
There was a problem hiding this comment.
No issues found across 4 files
Auto-approved: This PR adds safe query limits (pagination and take) to two unbounded Prisma queries in non-critical performance paths, preserving existing behavior and reducing risk of full-table scans without altering business logic.
Re-trigger cubic
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
|



Closes part of #1206 by bounding two critical unbounded Prisma queries in hot paths.
Summary
Birthday scheduler (
packages/bot/src/utils/general/birthdayScheduler.ts):Paginate
guildSettings.findMany()in role reconciliation withtake:500cursor-based pagination. Prevents full-table scans on large deployments when
reconciling guilds without birthday role matches.
Feedback service (
packages/bot/src/services/musicRecommendation/feedbackService.ts):Cap
userArtistPreference.findMany()withtake:5000to protect againstpower-user preference sprawl in the autoplay scoring path.
Implementation details
guildId ordering to safely traverse large result sets in 500-guild chunks.
against edge cases.
(pagination is transparent); feedback scoring includes all user prefs up to 5000.
Tests added
Follow-ups
recommended for further optimization (out of scope for this PR).
Summary by cubic
Bound two unbounded Prisma queries in hot paths to prevent full-table scans and reduce latency on large deployments. Addresses part of Linear #1206.
guildSettings.findManywith cursor-based 500-row pages ordered byguildIdto reconcile roles for guilds without matches without scanning the table.userArtistPreference.findManywithtake: 5000for preferred/blocked artist lookups in autoplay scoring.Written for commit 3f33b26. Summary will update on new commits.
Summary by CodeRabbit
Bug Fixes
Tests