- Unify API: lib/api.ts uses /api/v1, inbox uses /api/inbox (rewrites) - Remove localhost refs: openapi, inbox page - Add rewrites: /api/inbox|tmc -> inbox-server, /api/v1 -> FastAPI - Add stub routes: knowledge/insights, recommendations, search, log-error - Transfer from PAPA: prompts (inspection, tmc), scripts, supabase, data/tmc-requests - Fix inbox-server: ORDER BY created_at, package.json - Remove redundant app/api/inbox/files route (rewrites handle it) - knowledge/ in gitignore (large PDFs) Co-authored-by: Cursor <cursoragent@cursor.com>
29 lines
1.5 KiB
Python
29 lines
1.5 KiB
Python
"""
|
||
Модель для автоматических предупреждений о рисках.
|
||
|
||
Заполняется сервисом risk_scanner по данным: ТО (сроки, next_due), LLP, шасси,
|
||
дефекты (limit_date), сертификаты лётной годности (expiry_date) и т.п.
|
||
"""
|
||
|
||
from sqlalchemy import String, DateTime, Text, Boolean
|
||
from sqlalchemy.orm import Mapped, mapped_column
|
||
|
||
from app.db.base import Base
|
||
from app.models.common import TimestampMixin, uuid4_str
|
||
|
||
|
||
class RiskAlert(Base, TimestampMixin):
|
||
__tablename__ = "risk_alerts"
|
||
|
||
id: Mapped[str] = mapped_column(String(36), primary_key=True, default=uuid4_str)
|
||
entity_type: Mapped[str] = mapped_column(String(64), nullable=False, index=True, doc="maintenance_task | limited_life | landing_gear | defect_report | airworthiness_certificate")
|
||
entity_id: Mapped[str] = mapped_column(String(36), nullable=False, index=True)
|
||
aircraft_id: Mapped[str | None] = mapped_column(String(36), nullable=True, index=True)
|
||
|
||
severity: Mapped[str] = mapped_column(String(32), nullable=False, default="medium", doc="low | medium | high | critical")
|
||
title: Mapped[str] = mapped_column(String(255), nullable=False)
|
||
message: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||
due_at: Mapped[str | None] = mapped_column(DateTime(timezone=True), nullable=True)
|
||
is_resolved: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False)
|
||
resolved_at: Mapped[str | None] = mapped_column(DateTime(timezone=True), nullable=True)
|