feat(queue): implement form-expiry-check maintenance job
All checks were successful
Build & Push Docker Images / lint (pull_request) Successful in 1m0s
Build & Push Docker Images / build-and-push (pull_request) Has been skipped

Marks pending form_submissions whose expires_at has passed
as 'expired'. Logs the count of rows transitioned each run.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Matt Ciaccio
2026-04-27 21:58:14 +02:00
parent 999622fd08
commit f2c57c513e

View File

@@ -1,6 +1,9 @@
import { Worker, type Job } from 'bullmq';
import { and, eq, lt } from 'drizzle-orm';
import type { ConnectionOptions } from 'bullmq';
import { db } from '@/lib/db';
import { formSubmissions } from '@/lib/db/schema/documents';
import { logger } from '@/lib/logger';
import { QUEUE_CONFIGS } from '@/lib/queue';
@@ -15,8 +18,14 @@ export const maintenanceWorker = new Worker(
break;
}
case 'form-expiry-check': {
// TODO(L3): mark expired form submissions
logger.info('Form expiry check — not yet implemented');
const result = await db
.update(formSubmissions)
.set({ status: 'expired' })
.where(
and(eq(formSubmissions.status, 'pending'), lt(formSubmissions.expiresAt, new Date())),
)
.returning({ id: formSubmissions.id });
logger.info({ expired: result.length }, 'Form expiry check complete');
break;
}
default: