Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. from datetime import datetime
  2. import sqlalchemy as sa
  3. from celery import states
  4. from sqlalchemy import DateTime, String
  5. from sqlalchemy.orm import Mapped, mapped_column
  6. from libs.datetime_utils import naive_utc_now
  7. from models.base import Base
  8. from .engine import db
  9. class CeleryTask(Base):
  10. """Task result/status."""
  11. __tablename__ = "celery_taskmeta"
  12. id = mapped_column(sa.Integer, sa.Sequence("task_id_sequence"), primary_key=True, autoincrement=True)
  13. task_id = mapped_column(String(155), unique=True)
  14. status = mapped_column(String(50), default=states.PENDING)
  15. result = mapped_column(db.PickleType, nullable=True)
  16. date_done = mapped_column(
  17. DateTime,
  18. default=lambda: naive_utc_now(),
  19. onupdate=lambda: naive_utc_now(),
  20. nullable=True,
  21. )
  22. traceback = mapped_column(sa.Text, nullable=True)
  23. name = mapped_column(String(155), nullable=True)
  24. args = mapped_column(sa.LargeBinary, nullable=True)
  25. kwargs = mapped_column(sa.LargeBinary, nullable=True)
  26. worker = mapped_column(String(155), nullable=True)
  27. retries: Mapped[int | None] = mapped_column(sa.Integer, nullable=True)
  28. queue = mapped_column(String(155), nullable=True)
  29. class CeleryTaskSet(Base):
  30. """TaskSet result."""
  31. __tablename__ = "celery_tasksetmeta"
  32. id: Mapped[int] = mapped_column(
  33. sa.Integer, sa.Sequence("taskset_id_sequence"), autoincrement=True, primary_key=True
  34. )
  35. taskset_id = mapped_column(String(155), unique=True)
  36. result = mapped_column(db.PickleType, nullable=True)
  37. date_done: Mapped[datetime | None] = mapped_column(DateTime, default=lambda: naive_utc_now(), nullable=True)