add job to scheduler instead of running immediately (#23)

* add job to scheduler instead of running immediately

* fix test

* Apply suggestions from code review

* linting
This commit is contained in:
Matt
2025-10-21 16:23:48 -04:00
committed by GitHub
parent 35fdb8b615
commit 2739fbc897
2 changed files with 20 additions and 5 deletions

View File

@@ -1,3 +1,5 @@
from datetime import datetime
from apscheduler.schedulers.background import BackgroundScheduler
from app.core.database import SessionLocal
@@ -42,8 +44,13 @@ def start_scheduler_with_interval():
replace_existing=True,
)
if not scheduler.running:
# Run the job immediately once
job()
scheduler.add_job(
job,
"date",
run_date=datetime.now(),
id="initial_email_check",
replace_existing=True,
)
scheduler.start()
logger.info("Scheduler started.")
else: