"""
Progress Tracking Model
"""
import uuid
from sqlalchemy import Column, String, Integer, DateTime, func, ForeignKey
from sqlalchemy.dialects.postgresql import UUID as pgUUID
from sqlalchemy.orm import relationship
from .base import Base

class ProgressTracking(Base):
    __tablename__ = 'progress_tracking'

    id = Column(pgUUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
    report_id = Column(pgUUID(as_uuid=True), ForeignKey('reports.id'), nullable=False, index=True)
    step_name = Column(String, nullable=False)
    status = Column(String, nullable=False, default='pending', index=True)
    started_at = Column(DateTime, nullable=True)
    completed_at = Column(DateTime, nullable=True)
    duration_ms = Column(Integer)
    token_usage = Column(Integer)
    error_message = Column(String)

    report = relationship("Report", back_populates="progress_tracking")
