This commit is contained in:
Daniil
2026-04-07 13:42:45 +03:00
parent 7d2f444e1c
commit 259d3da89f
34 changed files with 2130 additions and 788 deletions
+3 -12
View File
@@ -1,6 +1,5 @@
from __future__ import annotations
import json
import logging
import uuid
@@ -30,13 +29,6 @@ JOB_TYPE_LABELS: dict[str, str] = {
"CAPTIONS_GENERATE": "Генерация субтитров",
}
STATUS_TITLES: dict[str, str] = {
"RUNNING": "Задача запущена",
"DONE": "Задача завершена",
"FAILED": "Ошибка выполнения",
}
# ---------------------------------------------------------------------------
# ConnectionManager — singleton for WebSocket pub/sub via Redis
# ---------------------------------------------------------------------------
@@ -113,14 +105,13 @@ class NotificationService:
# Only persist notifications on status changes (not progress-only updates)
notification_id: uuid.UUID | None = None
if notification_type is not None:
title = STATUS_TITLES.get(event.status or "", job_type_label)
notification = await self._repo.create(
NotificationCreate(
user_id=user_id,
job_id=job.id,
project_id=job.project_id,
notification_type=notification_type,
title=title,
title=job_type_label,
message=event.error_message or event.current_message,
payload={
"job_type": job.job_type,
@@ -139,8 +130,8 @@ class NotificationService:
job_id=job.id,
project_id=job.project_id,
job_type=job.job_type,
status=event.status or job.status,
progress_pct=event.progress_pct or job.project_pct,
status=event.status if event.status is not None else job.status,
progress_pct=job.project_pct if event.progress_pct is None else event.progress_pct,
message=event.error_message or event.current_message or job.current_message,
title=job_type_label,
created_at=now,