# import logging
# from pytz import timezone

# from app.utils.daily_data_insert import save_daily_data
# from apscheduler.schedulers.asyncio import AsyncIOScheduler
# from apscheduler.triggers.cron import CronTrigger

# scheduler = AsyncIOScheduler()
# log = logging.getLogger(__name__)

# # ======================
# # INITIALIZER (FastAPI)
# # ======================
# async def initialize_system_jobs():
#     """Initialize system jobs — called during FastAPI startup."""
#     log.info("Initializing system jobs...")

#     # Remove existing job if present
#     try:
#         scheduler.remove_job("daily_data_insert_job")
#     except Exception:
#         pass

#     scheduler.add_job(
#         id="daily_data_insert_job",
#         func=save_daily_data,
#         trigger=CronTrigger(
#             hour=8,
#             minute=0,
#             timezone=timezone("America/New_York")
#         ),
#         max_instances=1,
#         coalesce=True,
#         replace_existing=True
#     )

#     if not scheduler.running:
#         scheduler.start()

#     log.info("Daily data insert job scheduled for 4:00 AM ET")

# async def shutdown_system_jobs():
#     if scheduler.running:
#         scheduler.shutdown(wait=False)