Release v0.1.5
This commit is contained in:
27
src/govoplan_calendar/backend/tasks.py
Normal file
27
src/govoplan_calendar/backend/tasks.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from celery import shared_task
|
||||
|
||||
|
||||
@shared_task(name="govoplan_calendar.sync_due_caldav_sources")
|
||||
def sync_due_caldav_sources_task(tenant_id: str | None = None, limit: int = 50) -> list[dict[str, object]]:
|
||||
from govoplan_calendar.backend.service import sync_due_caldav_sources
|
||||
from govoplan_core.db.session import get_database
|
||||
|
||||
with get_database().SessionLocal() as session:
|
||||
results = sync_due_caldav_sources(session, tenant_id=tenant_id, limit=limit)
|
||||
session.commit()
|
||||
return [
|
||||
{
|
||||
"source_id": item.source_id,
|
||||
"calendar_id": item.calendar_id,
|
||||
"status": item.status,
|
||||
"error": item.error,
|
||||
"created": item.stats.created if item.stats else 0,
|
||||
"updated": item.stats.updated if item.stats else 0,
|
||||
"deleted": item.stats.deleted if item.stats else 0,
|
||||
"unchanged": item.stats.unchanged if item.stats else 0,
|
||||
"fetched": item.stats.fetched if item.stats else 0,
|
||||
}
|
||||
for item in results
|
||||
]
|
||||
Reference in New Issue
Block a user