nex_docus/backend/app/models/project_vectorization_task.py

38 lines
1.9 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

"""
项目向量化任务模型
"""
from sqlalchemy import BigInteger, Column, DateTime, Index, Integer, String, Text
from sqlalchemy.sql import func
from app.core.database import Base
class ProjectVectorizationTask(Base):
"""项目向量化后台任务表"""
__tablename__ = "project_vectorization_task"
id = Column(BigInteger, primary_key=True, autoincrement=True, comment="任务ID")
task_id = Column(String(64), nullable=False, unique=True, index=True, comment="任务唯一标识")
project_id = Column(BigInteger, nullable=False, index=True, comment="项目ID")
user_id = Column(BigInteger, nullable=False, index=True, comment="触发用户ID")
task_type = Column(String(32), nullable=False, comment="任务类型incremental/full")
status = Column(String(32), nullable=False, default="pending", index=True, comment="任务状态pending/running/success/failed")
total = Column(Integer, nullable=False, default=0, comment="文件总数")
processed = Column(Integer, nullable=False, default=0, comment="处理成功数")
skipped = Column(Integer, nullable=False, default=0, comment="跳过数")
failed = Column(Integer, nullable=False, default=0, comment="失败数")
error_message = Column(Text, comment="错误信息")
started_at = Column(DateTime, comment="开始时间")
finished_at = Column(DateTime, comment="完成时间")
created_at = Column(DateTime, server_default=func.now(), comment="创建时间")
updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now(), comment="更新时间")
__table_args__ = (
Index("idx_vector_task_project_status", "project_id", "status"),
Index("idx_vector_task_created_at", "created_at"),
)
def __repr__(self):
return f"<ProjectVectorizationTask(task_id='{self.task_id}', project_id={self.project_id}, status='{self.status}')>"