Fix cleanup job for unsubmitted forms#23
Conversation
- Fix date calculation for 7-day cutoff - Correct expiration query logic - Add submitted=false filter for unsubmitted forms - Safeguard against null entityId deletes - Scope relationship lookup to entityId - Improve performance by avoiding sequential processing - Ensure tokens are deleted even when relationships are missing
WalkthroughThe cleanup_unsubmitted_forms function is refactored from iterative per-token processing to a bulk transactional approach. It now recalculates a 7-day threshold, queries all expired unsubmitted tokens in a single operation, deduplicates entity and product IDs, and performs all deletions atomically within one Prisma transaction. The function signature explicitly declares Promise return type. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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 by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.