| 12345678910111213141516171819202122232425262728293031323334353637 |
- """Simulation task model for Web-Local dispatch (P4-M2)."""
- from sqlalchemy import Column, Integer, String, Float, DateTime, Text
- from sqlalchemy.sql import func
- from ..database import Base
- class Task(Base):
- """Simulation task dispatched from Web to Local executor."""
- __tablename__ = "tasks"
- id = Column(Integer, primary_key=True, index=True)
- task_id = Column(String(16), unique=True, index=True, nullable=False)
- task_name = Column(String(200), nullable=False)
- plan_id = Column(Integer, nullable=True)
- status = Column(String(20), default="pending", index=True)
- priority = Column(Integer, default=5)
- total_points = Column(Integer, default=0)
- completed_points = Column(Integer, default=0)
- task_dir = Column(String(500), nullable=True)
- task_file = Column(String(500), nullable=True)
- results_file = Column(String(500), nullable=True)
- progress_data = Column(Text, nullable=True)
- result_metrics = Column(Text, nullable=True)
- created_by = Column(String(50), default="web")
- created_at = Column(DateTime(timezone=True), server_default=func.now())
- dispatched_at = Column(DateTime(timezone=True), nullable=True)
- started_at = Column(DateTime(timezone=True), nullable=True)
- completed_at = Column(DateTime(timezone=True), nullable=True)
- # P3-M2: adaptive-batch task fields (backward compatible).
- task_type = Column(String(20), default="scan") # scan | adaptive_batch
- loop_id = Column(String(64), nullable=True, index=True)
- batch_id = Column(Integer, nullable=True)
- point_ids = Column(Text, nullable=True) # JSON list of point ids
- dynamic = Column(Integer, default=0) # 1 = more batches may follow
- duration = Column(Float, nullable=True)
|