-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Add domain, createdAt index #2481
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThe changes introduce or adjust ordering by Changes
Sequence Diagram(s)sequenceDiagram
participant Admin as Admin API (links)
participant DB as Database
Admin->>DB: Query links (with/without search)
alt search param not provided
DB-->>Admin: Return links created in last 30 days
else search provided
DB-->>Admin: Return matching links (no date filter)
end
sequenceDiagram
participant Cron as Cron Domain Delete
participant DB as Database
participant R2 as R2 Storage
participant Limiter as Rate Limiter
Cron->>DB: Fetch links ordered by createdAt DESC
Cron->>Limiter: Schedule image deletion for each link
Limiter->>R2: Delete image
Cron-->>Cron: (Domain/logo deletion logic commented out)
Cron-->>Cron: Log number of links found
Poem
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
apps/web/app/(ee)/api/admin/links/route.ts(1 hunks)apps/web/app/(ee)/api/cron/domains/delete/route.ts(4 hunks)apps/web/app/(ee)/api/cron/domains/transfer/route.ts(1 hunks)apps/web/app/(ee)/api/cron/domains/update/route.ts(1 hunks)apps/web/app/(ee)/api/cron/folders/delete/route.ts(1 hunks)apps/web/app/api/domains/route.ts(1 hunks)packages/prisma/schema/link.prisma(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
apps/web/app/(ee)/api/cron/domains/delete/route.ts (2)
apps/web/lib/storage.ts (1)
storage(151-151)packages/utils/src/constants/main.ts (1)
R2_URL(77-77)
🔇 Additional comments (10)
packages/prisma/schema/link.prisma (2)
91-91: Well-designed composite index for bulk operations.The new
[domain, createdAt]index is correctly structured withdomainas the leading column for filtering andcreatedAtfor efficient ordering in the bulk deletion workflows.
93-93: Improved documentation for existing index.The expanded comment better documents the multiple use cases for the
userIdindex, improving code maintainability.apps/web/app/(ee)/api/cron/domains/update/route.ts (1)
41-43: Excellent use of the new composite index.Adding
createdAt: "desc"ordering prioritizes processing of recently created links, which improves user experience for recent domain changes. This query will efficiently leverage the new[domain, createdAt]index.apps/web/app/api/domains/route.ts (1)
47-49: Minor query optimization through filter reordering.Reordering the
domainfilter before thekeyfilter is a good practice asdomainis likely more selective than checking for just two specific key values.apps/web/app/(ee)/api/cron/domains/transfer/route.ts (1)
32-34: LGTM! Consistent ordering for transfer operations.The addition of
orderBy: { createdAt: "desc" }ensures consistent processing order and prioritizes more recent links during transfer operations, which aligns with similar changes across other cron routes.apps/web/app/(ee)/api/cron/domains/delete/route.ts (5)
3-3: Good addition of rate limiting capability.Adding the
limiterimport enables proper rate limiting for storage operations, which is implemented well in the R2 deletion logic below.
46-49: LGTM! Consistent ordering pattern.The addition of
take: 100andorderBy: { createdAt: "desc" }maintains consistency with other cron routes and ensures predictable processing order.
52-52: Helpful logging for monitoring.The console log provides useful visibility into the deletion process.
68-72: Excellent rate limiting implementation for storage operations.Using
limiter.schedule()for R2 deletions prevents overwhelming the storage service and is a best practice for bulk operations.
112-131:Details
❓ Verification inconclusive
Critical functionality is disabled - verify if intentional.
The commented-out code disables two essential features:
- Re-queuing domain deletion jobs when links remain (lines 112-120)
- Final domain and logo deletion after all links are processed (lines 122-131)
This fundamentally changes the behavior from actually deleting domains to only deleting links. The response message still claims "Domain deleted" (line 134) but the domain isn't actually removed.
Please confirm if this is intentional (e.g., for testing/debugging) or if this code should be re-enabled:
🏁 Script executed:
#!/bin/bash # Check if there are any related tests or documentation about this change rg -A 5 -B 5 "queueDomainDeletion|Domain deleted" --type tsLength of output: 3636
Verify intentional removal of domain deletion and re-queuing
The cron route’s logic for
- re-queuing remaining link batches (formerly lines 112–120) and
- deleting the domain record and its logo (formerly lines 122–131)
is currently commented out. This means only the links are ever deleted, yet the response still claims “Domain deleted.”
Please confirm whether this change was intentional (e.g., for testing/debugging or a phased rollout). If not, you should:
- Re-enable
queueDomainDeletionwhenremainingLinks > 0- Restore the final
prisma.domain.deleteandstorage.deletecalls once all links are processed- Update the response message to reflect actual behavior
- Add or update tests covering the cron deletion workflow
Summary by CodeRabbit