FastAPI + Celery + Next.js + Postgres/Redis app with company monitoring, source collection, LLM-based change analysis, enrichment, and account security (Turnstile, escalating lockout, email verification).
30 lines
1.2 KiB
Python
30 lines
1.2 KiB
Python
from __future__ import annotations
|
|
|
|
import uuid
|
|
from typing import Any
|
|
|
|
from sqlalchemy import JSON, Enum, ForeignKey, String, Text
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from app.db.base import Base, TimestampMixin, UUIDPrimaryKeyMixin
|
|
from app.models.enums import ReportType
|
|
|
|
|
|
class Report(Base, UUIDPrimaryKeyMixin, TimestampMixin):
|
|
__tablename__ = "reports"
|
|
|
|
company_id: Mapped[uuid.UUID] = mapped_column(
|
|
ForeignKey("companies.id", ondelete="CASCADE"), index=True
|
|
)
|
|
monitoring_run_id: Mapped[uuid.UUID | None] = mapped_column(
|
|
ForeignKey("monitoring_runs.id", ondelete="SET NULL"), nullable=True, index=True
|
|
)
|
|
report_type: Mapped[ReportType] = mapped_column(Enum(ReportType, native_enum=False, length=20))
|
|
title: Mapped[str] = mapped_column(String(300))
|
|
executive_summary: Mapped[str] = mapped_column(Text)
|
|
structured_report: Mapped[dict[str, Any]] = mapped_column(JSON)
|
|
markdown_content: Mapped[str] = mapped_column(Text)
|
|
model_provider: Mapped[str] = mapped_column(String(50))
|
|
model_name: Mapped[str] = mapped_column(String(100))
|
|
prompt_version: Mapped[str] = mapped_column(String(20), default="v1")
|