Skip to content

Fix cleanup job for unsubmitted forms#23

Open
BrianKvin wants to merge 1 commit into
vula-africa:mainfrom
BrianKvin:fix/cleanup-unsubmitted-forms
Open

Fix cleanup job for unsubmitted forms#23
BrianKvin wants to merge 1 commit into
vula-africa:mainfrom
BrianKvin:fix/cleanup-unsubmitted-forms

Conversation

@BrianKvin
Copy link
Copy Markdown

@BrianKvin BrianKvin commented Jan 25, 2026

  • 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

Summary by CodeRabbit

  • Refactor
    • Optimized cleanup process for expired unsubmitted form data, improving system reliability and performance through streamlined operations.

✏️ Tip: You can customize this high-level summary in your review settings.

- 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
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jan 25, 2026

Walkthrough

The 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

Cohort / File(s) Summary
Bulk Transaction Refactoring
tests/unsubmitted_forms/cleanup_unsubmitted_forms.ts
Converts iterative per-token cleanup to single bulk transactional operation. Adds ExpiredToken interface. Implements sevenDaysAgo date calculation, batches all expired token queries, deduplicates IDs, and consolidates relationship/corpus/token/entity deletions into one Prisma transaction. Updates function signature to explicitly return Promise.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 A hop, skip, and refactor so bold!
From token-by-token to transactions of gold,
Bulk operations dance in atomic grace,
Cleaning up forms at a much faster pace,
Seven days gone in one swift embrace! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix cleanup job for unsubmitted forms' directly aligns with the main objective of fixing the cleanup job implementation, specifically addressing issues with date calculation, expiration query logic, and performance improvements.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant