import { db } from '@/lib/db';
import { ports } from '@/lib/db/schema/ports';
import { processReminderQueue } from '@/lib/services/document-reminders';
import { logger } from '@/lib/logger';

export async function processDocumentReminders(): Promise<void> {
  const allPorts = await db.select({ id: ports.id }).from(ports);

  for (const port of allPorts) {
    try {
      await processReminderQueue(port.id);
    } catch (err) {
      logger.error({ err, portId: port.id }, 'Reminder processing failed');
    }
  }
}
