Watch
1
0
Fork
You've already forked Seyyed_arc
0
forked from hesabix/arc
Seyyed_arc/hesabixAPI/app/services/oa_background_jobs.py
Babak Alizadeh 6a5e60c87d feat(office-automation): add commercial correspondence suite
Bring secretariats, ECE 1.01, multi-sign, archive, public tracking, and due-followup alerts into the OA plugin, with fa/en UI and existing workflow/SMS reuse.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-02 15:15:33 +03:30

35 lines
1.2 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# noqa: D100
"""Jobهای پس‌زمینه اتوماسیون اداری: هشدار سررسید پیگیری و مهلت ارجاع."""
from __future__ import annotations
import logging
from typing import Dict
logger = logging.getLogger(__name__)
def tick_once() -> Dict[str, Dict]:
"""یک بار اجرای هشدارهای سررسید نامه و ارجاع."""
from adapters.db.session import get_db_session
from app.services.office_automation_extended_service import notify_due_followups
out: Dict[str, Dict] = {}
with get_db_session() as db:
try:
out["due_followups"] = notify_due_followups(db)
except Exception as e:
logger.error("OA due-followup tick failed: %s", e, exc_info=True)
out["due_followups"] = {"error": str(e)}
return out
async def oa_automation_background_loop(interval_seconds: int = 300) -> None:
"""حلقه پس‌زمینه: هر چند دقیقه هشدار سررسید کارتابل را ارسال می‌کند."""
import asyncio
while True:
try:
await asyncio.to_thread(tick_once)
except Exception:
logger.exception("oa_automation_background_loop tick error")
await asyncio.sleep(max(60, int(interval_seconds)))