# import logging
# from apscheduler.schedulers.background import BackgroundScheduler
# from django.core.mail import send_mail
# from django.urls import reverse
# from django.contrib.sites.shortcuts import get_current_site
# from django.conf import settings

# logger = logging.getLogger(__name__)

# def every_10_minutes_job():
#     logger.info("[Scheduler] [ 600 Seconds] Start")
#     logger.info("[Scheduler] [ 600 Seconds] Complete")


# def send_assistance_required_email():
#     from leads.models import ApplicationAssistance
#     tmp = ApplicationAssistance.objects.filter(status='pending')
#     if tmp.count()>=1:
#         path = reverse('assistance_list')
#         domain = settings.SITE_DOMAIN
#         protocol = settings.SITE_PROTOCOL
#         link = f"{protocol}://{domain}{path}"
#         print(link)
#         msg = f'There are {tmp.count()} users requesting assistance.\nClick link below to view:\n{link}'
#         send_mail(
#             subject='Pending Application Assistance ',
#             message=msg,
#             from_email=None,  # uses DEFAULT_FROM_EMAIL
#             recipient_list=['raj@avenirtechcorp.com','info@registeryourstartup.com'],
#             fail_silently=False,
#         )

# def every_2_minutes_job():
#     logger.info("[Scheduler] [120 Seconds] Start")
#     send_assistance_required_email()
#     logger.info("[Scheduler] [120 Seconds] Complete")



# def start():
#     scheduler = BackgroundScheduler(timezone="Asia/Kolkata")

#     # 👇 In-memory jobstore (no DB locks)
#     # remove DjangoJobStore()
#     # scheduler.add_jobstore('memory')

#     scheduler.add_job(
#         every_10_minutes_job,
#         trigger="interval",
#         seconds=600,
#         id="ten_minute_job",
#         replace_existing=True,
#     )

#     scheduler.add_job(
#         every_2_minutes_job,
#         trigger="interval",
#         seconds=120,
#         id="every_2_minutes_job",
#         replace_existing=True,
#     )

# # 🔧 Example: Run every Monday at 8:15 AM
#     # scheduler.add_job(
#     #     every_10_minutes_job,
#     #     trigger="cron",
#     #     day_of_week="mon",
#     #     hour=8,
#     #     minute=15,
#     #     id="test_job",
#     #     replace_existing=True,
#     # )

# # 🔧 Example: Run multiple times a day (e.g., 9:00 AM and 6:00 PM)
#     # scheduler.add_job(
#     #     every_10_minutes_job,
#     #     trigger="cron",
#     #     hour="9,18",  # comma separated
#     #     minute=0,
#     #     id="test_job",
#     #     replace_existing=True,
#     # )
# # 🔧 Example: Run every day at 2:30 AM
#     # scheduler.add_job(
#     #     every_10_minutes_job,
#     #     trigger="cron",
#     #     hour=2,
#     #     minute=30,
#     #     id="test_job",
#     #     replace_existing=True,
#     # )



#     scheduler.start()
#     logger.info("Scheduler started...")
