"""Job model.""" from typing import Any from sqlalchemy import Column, ForeignKey from sqlalchemy.dialects.mysql import INTEGER, VARCHAR from video.connectors import mysql from video.models.sql.classes import base_mixin class Job(mysql.BaseModel, base_mixin.BaseMixin): """Job model.""" __tablename__ = "jobs" job_type = Column( VARCHAR(length=280), name="type", nullable=False, ) parent_id = Column( INTEGER(unsigned=True), ForeignKey("jobs.id"), ) context_id = Column( INTEGER(unsigned=True), ForeignKey("contexts.id"), nullable=False, ) def to_dict(self) -> dict[str, Any]: """Get a dict representation of a Job.""" data = super(Job, self).to_dict() data.update( { "type": self.job_type, "parent_id": self.parent_id, "context_id": self.context_id, } ) return data