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

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