Initial commit for eventlens

This commit is contained in:
ecki
2026-04-09 19:00:12 +02:00
commit 51aab152ff
21 changed files with 1862 additions and 0 deletions
+40
View File
@@ -0,0 +1,40 @@
from apscheduler.schedulers.background import BackgroundScheduler
from app.config import settings
from app.database import SessionLocal
from app.services import run_sync, send_reminders
scheduler = BackgroundScheduler(timezone="Europe/Berlin")
def sync_job():
with SessionLocal() as db:
run_sync(db)
def reminder_job():
with SessionLocal() as db:
send_reminders(db)
def start_scheduler():
if scheduler.running:
return
scheduler.add_job(
sync_job,
"interval",
hours=settings.poll_interval_hours,
id="sync_job",
replace_existing=True,
)
scheduler.add_job(
reminder_job,
"interval",
hours=settings.reminder_interval_hours,
id="reminder_job",
replace_existing=True,
)
scheduler.start()