import { FetchNotifyEmail } from '../services/expirePlanNotify.job';
import { updateLeadScore } from '../services/UpdateLeadScore';
import { CheckExpiredCompanies } from '../services/CheckExpiredCompanies.job';
import { scheduleIstTask } from './cron.service';

export const initCompanyCronJob = () => {
  // 1. Check Expired Companies: Every day at midnight IST (00:00)
  scheduleIstTask(
    '0 0 * * *',
    CheckExpiredCompanies,
    'Expired companies checked',
  );

  // 2. Fetch and Notify Expiring Plans: Every day at 3:00 AM IST (03:00)
  scheduleIstTask(
    '0 3 * * *',
    FetchNotifyEmail,
    'Expired plan notifications processed',
  );

  // 3. Update Lead Score: Every Sunday at midnight IST (00:00, day 0)
  scheduleIstTask('0 0 * * 0', updateLeadScore, 'Weekly lead scores updated');
};
