from __future__ import annotations

from sqlalchemy import BigInteger, Boolean, Integer, String, Text
from sqlalchemy.orm import Mapped, mapped_column

from fastapi_common.fastapi_common_web.models import BaseModel


class LeauditRagDocument(BaseModel):
    __tablename__ = "rag_document"

    Id: Mapped[int] = mapped_column("id", BigInteger, primary_key=True, autoincrement=True)
    datasetId: Mapped[int] = mapped_column("dataset_id", BigInteger)
    filename: Mapped[str] = mapped_column(String(500))
    originalName: Mapped[str] = mapped_column("original_name", String(500))
    minioPath: Mapped[str] = mapped_column("minio_path", String(1000))
    fileType: Mapped[str] = mapped_column("file_type", String(20))
    fileSize: Mapped[int] = mapped_column("file_size", BigInteger, default=0)
    chunkCount: Mapped[int] = mapped_column("chunk_count", Integer, default=0)
    indexingStatus: Mapped[str] = mapped_column("indexing_status", String(20), default="pending")
    indexingError: Mapped[str | None] = mapped_column("indexing_error", Text)
    enabled: Mapped[bool] = mapped_column(Boolean, default=True)
    hitCount: Mapped[int] = mapped_column("hit_count", Integer, default=0)
    createdBy: Mapped[int | None] = mapped_column("created_by", BigInteger)
