/**
 * Cron script to automate user verification reminders and cleanup.
 * Run this nightly or once per day.
 */

const userService = require('../services/userService');

async function runCleanup() {
    console.log(`[${new Date().toISOString()}] Starting User Verification Cleanup Cron...`);
    try {
        const stats = await userService.performUnverifiedCleanup();
        console.log(`[${new Date().toISOString()}] Cleanup Finished.`);
        console.log(`- Reminders Sent (6-day): ${stats.remindersSent}`);
        console.log(`- Accounts Deleted (7-day): ${stats.accountsDeleted}`);
        process.exit(0);
    } catch (error) {
        console.error(`[${new Date().toISOString()}] Cleanup Failed:`, error);
        process.exit(1);
    }
}

runCleanup();
